mKeRix/ansible-playbooks

Playbook not working for Raspberry Pi 3

Burningstone91 opened this issue · 3 comments

Thanks for the Ansible playbook, great work!

It worked sucessfully (there's an issue with bluetooth Low Energy, however I don't think it's related to the Ansible playbook) on my 5 Pi Zero W's, but it fail on a Raspberry Pi 3, looks like something with permissions.

I get this error at the step "Ensure dependencies are present." from the ggerlingguy.nodejs role:

fatal: [10.10.70.10]: FAILED! => {"cache_update_time": 1586636083, "cache_updated": false, "changed": false, "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" install 'apt-transport-https' 'gnupg2'' failed: E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?\n", "rc": 100, "stderr": "E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)\nE: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?\n", "stderr_lines": ["E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)", "E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?"], "stdout": "", "stdout_lines": []}

If I manually install these libraries on the remote, I get an error at the next step:

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

I'm new to Ansible, so I'm not sure if it's an issue from my side or not.

That's an issue with the playbook, it's not elevating the permissions for those steps correctly. Could you test something for me quickly? If it works I'll include the change in the repository.

In roles/nodejs/tasks/main.yml add the line become: yes to the import_role step. It should look like this:

- import_tasks: armv6.yml
  when: ansible_architecture == 'armv6l'
- import_role:
    name: geerlingguy.nodejs
  vars:
    nodejs_version: "12.x"
  become: yes
  when: ansible_architecture != 'armv6l'

Then try re-running the playbook and see if it installs fine on your Pi 3 now.

I can confirm that become: yes worked.

@mKeRix I found this solution myself yesterday in the evening and can confirm it works. I wanted to post it now but saw you were quicker :)
I see you already made a commit to change this, thanks great work!

Btw your work on room-assistant is highly appreciated, I use it for two years now and it has always been the most reliable part of my system. I used it just for "home" and "not_home" but I'm now going to play with some room automations and ansible makes testing really easy. Thanks again!