--- # tasks file for ansible - name: install ansible block: - name: install ansible package (allowed to fail) package: name: "{{ ansible_packages }}" state: present register: ansible_install_ansible_package until: ansible_install_ansible_package is succeeded retries: 3 rescue: - name: install ansible pip pip: name: ansible state: present register: ansible_install_ansible_pip until: ansible_install_ansible_pip is succeeded retries: 3 - name: ensure the ansible directory exists file: path: /etc/ansible state: directory - name: mark configuration file as ansible managed lineinfile: path: "{{ ansible_configuration_directory }}/{{ ansible_configuration_file }}" create: yes insertbefore: BOF line: "# This file is managed by Ansible." - name: configure ansible ini_file: path: "{{ ansible_configuration_directory }}/{{ ansible_configuration_file }}" section: "{{ item.section | default('defaults') }}" option: "{{ item.option }}" value: "{{ item.value }}" with_items: - "{{ ansible_configuration }}" loop_control: label: "{{ item.option }}"