--- - name: Prepare hosts: localhost connection: local pre_tasks: - name: "Create MySQL Container" docker_container: name: mysql-host image: mysql:5.7 state: started recreate: yes networks: - name: zabbix env: MYSQL_ROOT_PASSWORD: changeme no_log: true with_items: "{{ molecule_yml.platforms }}" when: - '"mysql" in item.groups' - name: "Create postgresql Container" docker_container: name: postgresql-host image: postgres state: started recreate: yes networks: - name: zabbix env: POSTGRES_PASSWORD: changeme no_log: true with_items: "{{ molecule_yml.platforms }}" when: - '"postgresql" in item.groups' - name: Prepare hosts: all tasks: - name: "Set short version name" set_fact: zabbix_python_prefix: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}" - name: "Create group for imaginary host" add_host: name: imaginary-host groups: - mysql - postgresql changed_when: False - name: "Installing packages on CentOS" yum: name: - net-tools - which - sudo state: present register: installation_dependencies until: installation_dependencies is succeeded when: - ansible_os_family == 'RedHat' - name: "Installing packages on CentOS" yum: name: - mysql state: present register: installation_dependencies until: installation_dependencies is succeeded when: - ansible_os_family == 'RedHat' - inventory_hostname in groups['mysql'] - name: "Apt update" shell: "apt-get update && echo exit 0 > /usr/sbin/policy-rc.d" args: warn: False register: installation_dependencies until: installation_dependencies is succeeded when: - ansible_os_family != 'RedHat' - name: "Installing packages on NON-CentOS" apt: name: - net-tools - apt-utils - "{{ zabbix_python_prefix }}-pip" - gpg-agent - sudo - doc-base update_cache: True state: present register: installation_dependencies until: installation_dependencies is succeeded when: - ansible_os_family != 'RedHat' - name: "Configure SUDO." lineinfile: dest: /etc/sudoers line: "Defaults !requiretty" state: present - name: "Make sure the docs can be installed. (RedHat)" lineinfile: dest: /etc/yum.conf line: "tsflags=nodocs" state: absent when: - ansible_os_family == 'RedHat' - name: "Make sure the docs can be installed. (Debian)" lineinfile: path: /etc/dpkg/dpkg.cfg.d/excludes state: absent regexp: 'path-exclude=/usr/share/doc/*' when: - ansible_os_family != 'RedHat' - name: PyMySQL pip: name: PyMySQL register: installation_dependencies until: installation_dependencies is succeeded when: - inventory_hostname in groups['mysql']