--- - name: Load in local SSH key path set_fact: my_ssh_key: "/root/.ssh/id_rsa.pub" when: inventory_hostname in groups['manager'] - name: Local user has an SSH key command: stat {{ my_ssh_key }} changed_when: false run_once: true when: inventory_hostname in groups['manager'] - name: Install python-apt to use ansible apt module shell: apt update && apt install -y python-apt - name: Ensure python and other dependencies are installed. apt: name: - apt-transport-https - ca-certificates - gnupg - python-pip #- python-docker state: present - name: pip install docker pip: name: docker state: present - name: Add docker gpg key #shell: wget https://download.docker.com/linux/debian/gpg -O - | apt-key add - apt_key: url: "https://download.docker.com/linux/debian/gpg" state: present - name: Add docker stable repository for debian apt_repository: repo: "deb https://download.docker.com/linux/debian stretch stable" state: present - name: Install lxc & docker apt: name: - lxc - docker - docker-ce - python-lxc when: inventory_hostname in groups['manager'] - name: Install docker on worker nodes apt: name: - docker-ce when: inventory_hostname in groups['workers'] - name: Fix docker module missing issue command: touch /.dockerenv run_once: true when: inventory_hostname in groups['workers'] notify: Restart docker