Untitled

 avatar
unknown
plain_text
2 years ago
1.8 kB
3
Indexable
    - name: Check if Docker is installed
      ansible.builtin.debug:
        msg: "{{ ansible_facts.packages['docker-ce'] }} versions of docker are installed!"
      when: "'docker-ce' in ansible_facts.packages"

    - name: update docker if not the correct version
      when: ansible_facts.name['docker-ce'].version != '5:20.10.22~3-0~ubuntu-bionic'
      delegate_to: rke.home.kjones.me
      ansible.builtin.apt:
        name: docker-ce=5:20.10.22~3-0~ubuntu-bionic
        state: present
        update_cache: yes


TASK [Gather package facts] *********************************************************************************************************
ok: [localhost -> rke.home.kjones.me]

TASK [Check if Docker is installed] *************************************************************************************************
ok: [localhost] => {
    "msg": "[{'name': 'docker-ce', 'version': '5:19.03.14~3-0~ubuntu-bionic', 'arch': 'amd64', 'category': 'admin', 'origin': 'Docker', 'source': 'apt'}] versions of docker are installed!"
}

TASK [update docker if not the correct version] *************************************************************************************
fatal: [localhost -> rke.home.kjones.me]: FAILED! => {"msg": "The conditional check 'ansible_facts.name['docker-ce'].version != '5:20.10.22~3-0~ubuntu-bionic'' failed. The error was: error while evaluating conditional (ansible_facts.name['docker-ce'].version != '5:20.10.22~3-0~ubuntu-bionic'): 'dict object' has no attribute 'name'\n\nThe error appears to be in '/home/keith/ansible/test.yml': line 40, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: update docker if not the correct version\n      ^ here\n"}
Editor is loading...