this is my playbook:
---
- name: installing docker on ubuntu
hosts: localhost
remote_user: "{{ remote_user_name }}"
gather_facts: no
vars_files:
- var_docker.yml
vars:
remote_user_name: cyber01
apt_repo_data: "deb [arch=amd64]
tasks:
- vmware_guest:
hostname: "{{ VMWARE_HOST }}"
username: "{{ VMWARE_USER }}"
password: "{{ VMWARE_PASSWORD }}"
validate_certs: no
folder: /ha-datacenter/vm/
name: my_vm_01
- name: adding docker gpg key
apt_key:
url: "{{ apt_gpg_key }}"
state: present
- name: add docker repository
apt_repository:
repo: "{{ apt_repo_data }}"
state: present
- name: installing docker-ce
apt:
name: docker-ce
state: present
update_cache: yes
- name: install python-pip
apt:
name: python-pip
state: present
- name: install docker-py
pip:
name: docker-py
state: present
run playbook: ansible-playbook -i hosts docker_contairner.yml
PLAY [installing docker on ubuntu] *********************************************
TASK [vmware_guest] ************************************************************
ok: [my_vm_01]
TASK [adding docker gpg key] ***************************************************
fatal: [my_vm_01]: FAILED! => {"changed": false, "cmd": "/usr/bin/apt-key add -", "msg": "Warning: apt-key output should not be parsed (stdout is not a terminal)\nE: This command can only be used by root.", "rc": 1, "stderr": "Warning: apt-key output should not be parsed (stdout is not a terminal)\nE: This command can only be used by root.\n", "stderr_lines": ["Warning: apt-key output should not be parsed (stdout is not a terminal)", "E: This command can only be used by root."], "stdout": "", "stdout_lines": []}