Many tasks are failing in ansible provision.yml

See original GitHub issue

Postgres

My first time using Ansible and running ansible-playbook provision.yml -i stages/stage.yml fails on task Creates postgres database:

TASK [Creates postgres database] ***************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: psycopg2.OperationalError: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  Peer authentication failed for user "postgres"
fatal: [stage1]: FAILED! => {"changed": false, "msg": "unable to connect to database: connection to server on socket \"/var/run/postgresql/.s.PGSQL.5432\" failed: FATAL:  Peer authentication failed for user \"postgres\"\n"}

Googled a bit and found that adding this to task, fixes it:

    - name: Creates postgres database
      become: true
      become_user: postgres

Then with the next task Creates postgres user same issue, adding that again fixed it 😉

Other

After postgres, other tasks were failing because their directories didn’t exist, such as /mnt/persist/uwsgi/conf.d/, /mnt/persist/nginx/conf.d/, /mnt/persist/nodejs/ and /mnt/persist/etc/


I don’t know if all of this is happening just with my server or not, just wanted to let you guys know… Did I forget to run something? Server is DigitalOcean’s droplet with an Ubuntu 20.04 (LTS) x64 on it.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
marteinncommented, Jul 13, 2022

@tekhi Forgot to reply, apologies 😃

Why uWSGI? Very good question. No particular reason really. uWSGI and Gunicorn are very similar looking at the problem they aim to solve and how they do it. They also have similar performance. The differences, at least from what I can tell, is that Gunicorn might be more beginner friendly and easier to configure, while uWSGI has more extensible configuration.

I would go with any of them as I don’t think it matters. We just happen to include pick uWSGI here.

When it comes to setting up services for uWSGI/Gunicorn, it is very important indeed. We don’t include a systemd-job in this boilerplate as it is already included at our preferred hosting provider.

1reaction
marteinncommented, Jul 13, 2022

Yeah, but keep in mind, in a CI context this is not an issue and we only run the ~provision~ deploy playbook from there 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Handling In Playbooks - Ansible Documentation
When a task fails on a host, handlers which were previously notified will not be run on that host. This can lead to...
Read more >
Ansible failed without any errors · Issue #71306 - GitHub
The following playbook have no failed tasks (only rescued), but the exit code of "ansible-playbook" is 2. Also AWX marks this job as...
Read more >
An Ansible playbook for solving a new problem from scratch
ansible -playbook addauser.yml $ sudo chage -l pentest [sudo] ... You don't want to fail on a single error when you have multiple...
Read more >
Ansible Ignore errors in tasks and fail at end of the playbook if ...
XY problem I think. ansible default behavior is to tell you which hosts failed at the end. If you use ignore_errors, ansible will...
Read more >
Working with Ansible Playbooks - Tips & Tricks with Examples
Every task is associated with a module responsible for an action and its configuration parameters. Since most tasks are idempotent, we can ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found