docker installation problems

221 views
Skip to first unread message

rebecca acheampong

unread,
Apr 26, 2021, 6:21:06 AM4/26/21
to Ansible Project
I am using ansible to install a docker but I get this error. How can i solve this please?
Please help me, this installation has taken me a whole week

Control node is ubuntu server 20.04
Target node is ubuntu desktop 18.04 on vmware esxi

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": []}

Thanh Nguyen Duc

unread,
Apr 26, 2021, 6:27:33 AM4/26/21
to ansible...@googlegroups.com
Look like you need to add become_user option there

Sent from my iPhone

On 26 Apr 2021, at 18:21, rebecca acheampong <bec1...@gmail.com> wrote:

I am using ansible to install a docker but I get this error. How can i solve this please?
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/eac60358-57e0-4f9f-ad03-377ec881f6e2n%40googlegroups.com.

rebecca acheampong

unread,
Apr 26, 2021, 6:30:30 AM4/26/21
to Ansible Project
I just added become_user: root but the same problem

Thanh Nguyen Duc

unread,
Apr 26, 2021, 6:45:48 AM4/26/21
to ansible...@googlegroups.com
Sorry, it should be become: true
By default it will elevate the account to root. You may need to pass become_user_pass as well.

Sent from my iPhone

On 26 Apr 2021, at 18:30, rebecca acheampong <bec1...@gmail.com> wrote:

I just added become_user: root but the same problem

Dick Visser

unread,
Apr 26, 2021, 6:47:06 AM4/26/21
to ansible...@googlegroups.com
You're using localhost as the target, which is OK for the vmware
module (as that is an API based one), but then you also target
localhost for the docker stuff.
Split your deployment into separate playbook and make sure you're
targeting the correct host.
This may involve add_host etc.
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/eac60358-57e0-4f9f-ad03-377ec881f6e2n%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

rebecca acheampong

unread,
Apr 26, 2021, 7:05:14 AM4/26/21
to Ansible Project
I added become_user: true
               become_user_pass: true
I got the same error without the pass, but when i add the pass, i get this:
ERROR! 'become_user_pass' is not a valid attribute for a Play


rebecca acheampong

unread,
Apr 26, 2021, 7:07:52 AM4/26/21
to Ansible Project

I wish i could separate them as you have told me but i am very new to ansible and I am using it for my final project. I dont know how to do that. I changed the host to the target node's name. I think you are right because the localhost does the installation of the docker on the control node. But I do not know what to do.

Mauricio Tavares

unread,
Apr 26, 2021, 7:39:53 AM4/26/21
to ansible...@googlegroups.com
On Mon, Apr 26, 2021 at 7:07 AM rebecca acheampong <bec1...@gmail.com> wrote:
>
>
> I wish i could separate them as you have told me but i am very new to ansible and I am using it for my final project. I dont know how to do that. I changed the host to the target node's name. I think you are right because the localhost does the installation of the docker on the control node. But I do not know what to do.

Here is a sample ansible playbook; don't know who wrote it. Take a
look at it. Ask questions. Once you understand it, what you are trying
to do should make sense.

https://www.ansible.com/blog/getting-started-writing-your-first-playbook
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ebd3bf51-8f39-40b3-b8bb-276bcaefa594n%40googlegroups.com.

Nuno Jordão

unread,
Apr 26, 2021, 7:45:13 AM4/26/21
to ansible...@googlegroups.com
A playbook is a list of plays. Example:

---
- name: play1
  hosts: host1
  tasks:
    - name:
       etc...

- name: play2
  hosts: host2
  tasks:
    - name:

rebecca acheampong

unread,
Apr 26, 2021, 7:46:44 AM4/26/21
to ansible...@googlegroups.com
Thank you so much. I am looking at it

rebecca acheampong

unread,
Apr 26, 2021, 7:48:48 AM4/26/21
to ansible...@googlegroups.com
Thank you very much...taking a look at it

Reply all
Reply to author
Forward
0 new messages