--- - name: Prepare hosts: all gather_facts: False tasks: - name: Install python for Ansible raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal) become: True changed_when: False - hosts: all become: yes tasks: - name: Update all caches to avoid errors due to missing remote archives apt: update_cache: yes changed_when: False - name: Deploy CA certificate copy: src: tests/data/x509/ca.cert.pem dest: /etc/ssl/certs/testca.cert.pem owner: root group: root mode: 0644 - hosts: client become: yes tasks: - name: Install tool for teting TCP connectivity apt: name: hping3 state: installed - hosts: parameters-optional become: yes tasks: - name: Set-up the hosts file lineinfile: path: /etc/hosts regexp: "^{{ item.key }}" line: "{{ item.key }} {{ item.value }}" owner: root group: root mode: 0644 state: present with_dict: 127.0.2.1: parameters-optional - hosts: parameters-mandatory become: yes tasks: - name: Set-up the hosts file lineinfile: path: /etc/hosts regexp: "^{{ item.key }}" line: "{{ item.key }} {{ item.value }}" owner: root group: root mode: 0644 state: present with_dict: 127.0.2.1: parameters-mandatory.local