nickjj / ansible-docker

Install / Configure Docker and Docker Compose using Ansible.
MIT License
750 stars 224 forks source link

Failed : Install Docker's dependencies #101

Closed TheSaM07 closed 3 years ago

TheSaM07 commented 3 years ago

Hello, I have two servers which are the same, on the first one the role is running fine, but on the other one, I get these errors, anyone knows where I have to look.

FAILED! => {"changed": false, "msg": "'/usr/bin/apt-mark manual apt-transport-https ca-certificates cron gnupg2 software-properties-common gcc python3-setuptools python3-dev python3-pip virtualenv' failed: E: Could not create temporary file for /var/lib/apt/extended_states - mkstemp (13: Permission denied)\nE: Failed to write temporary StateFile /var/lib/apt/extended_states\n", "rc": 100, "stderr": "E: Could not create temporary file for /var/lib/apt/extended_states - mkstemp (13: Permission denied)\nE: Failed to write temporary StateFile /var/lib/apt/extended_states\n", "stderr_lines": ["E: Could not create temporary file for /var/lib/apt/extended_states - mkstemp (13: Permission denied)", "E: Failed to write temporary StateFile /var/lib/apt/extended_states"], "stdout": "apt-transport-https was already set to manually installed.\ngnupg2 can not be marked as it is not installed.\npython3-setuptools was already set to manually installed.\npython3-pip was already set to manually installed.\nvirtualenv can not be marked as it is not installed.\n", "stdout_lines": ["apt-transport-https was already set to manually installed.", "gnupg2 can not be marked as it is not installed.", "python3-setuptools was already set to manually installed.", "python3-pip was already set to manually installed.", "virtualenv can not be marked as it is not installed."]}

Same user, sudo group.

nickjj commented 3 years ago

Hi,

That typically happens when something bad happens with apt (package installation failure, etc.).

I'm not sure what you did exactly but I see you closed this issue. What did you end up doing?

TheSaM07 commented 3 years ago

Hello, thanks for your reply. As I do not know what's wrong with the vm, but I have done many things with apt, nothing successful. I was able to install the dependencies manually with sudo apt, but now I have this error at Add Docker's public GPG key : FAILED! => {"changed": false, "cmd": "/usr/bin/apt-key add -", "msg": "Warning: apt-key output should not be parsed

They should be both the same as nothing was installed on it but the OS, that's why I've asked the team for a new install of both, I've closed the issue for now and I will try to redeploy again when they're up, because as you've said that's nothing related to the role. Regards

TheSaM07 commented 3 years ago

With a fresh install of ubuntu I still have the problem on both. Any ideas ?

image

TheSaM07 commented 3 years ago

Resolved : add to change docker.yml and add the following line :


docker.yml

nickjj commented 3 years ago

What version of Ubuntu are you using?

TheSaM07 commented 3 years ago

image

nickjj commented 3 years ago

Interesting, I've never seen that error and I've installed this role dozens of times on Ubuntu 20.04.

What version of Ansible are you using?

I also never had to set become_method: sudo because sudo is the default. Maybe you overrode Ansible's defaults in your ansible.cfg file? You can see it's the default based on https://github.com/ansible/ansible/blob/4b673484f06fa9464601c27706c8a43d1e11bbcb/examples/ansible.cfg#L341.

TheSaM07 commented 3 years ago

ansible --version returns : image

I did not change the ansible.cfg The thing is that I use the devops azure as repository for the yml files and I run ansible playbooks from there with a release pipeline.

Well, I had many issues but you're right, I have removed become_method and it's still working. I was using become_user = administrator, it was working on only one node before the new install of the vms. Right now, it's working and I'm new with ansible so I do make mistakes for sure ;) Thanks for your work.

nickjj commented 3 years ago

Ah that makes sense then. When in doubt check the readme's example playbook. It has everything you need at the playbook level to make things work, which in this case is setting become: true because root access is needed by this role to apt install packages and create certain config files in various /etc paths, etc..

Often times you'll create some type of admin user and run Ansible as that user. Setting become: true makes sure tasks are run with sudo by default, otherwise you would run into permission issues for that admin user when encountering tasks that require root.