# Playboox only runs the second time

**URL:** <https://forum.ansible.com/t/playboox-only-runs-the-second-time/33456>\
**Category:** Ansible Project\
**Created:** [July 21, 2020, 6:51pm UTC](https://forum.ansible.com/t/playboox-only-runs-the-second-time/33456 "2020-07-21T18:51:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![robert\_rottermann](https://avatars.discourse-cdn.com/v4/letter/r/4bbf92/32.png) [@robert\_rottermann](https://forum.ansible.com/u/robert_rottermann)\
**Post date:** [July 21, 2020, 6:51pm UTC](https://forum.ansible.com/t/playboox-only-runs-the-second-time/33456/1 "2020-07-21T18:51:10Z")

</div>

Hi friends in Ansible  
I have a playbook that sets up a PostgreSQL environment.  
One of the tasks sets up a db user.  
This task always fails the first time. The error is, that psycopg2 could not be loaded.  
If I run the playbook a second time, it works without a glitch.

A clumsy solution I found is to split the playbook into two parts. Running them in sequence work without a problem.

Could anybody of you give me a hint on how to find a solution for this?

thanks  
Robert

here is the failing task:

- name: PostgreSQL - Add the config db Odoo user  
become: true  
become\_user: postgres  
postgresql\_user:  
name: ‘{{ odoo\_config\_db\_user }}’  
password: ‘{{ odoo\_config\_db\_passwd\_crypt }}’  
encrypted: yes  
role\_attr\_flags: ‘{{ odoo\_postgresql\_user\_role\_attr }}’  
ignore\_errors: yes

---

<div class="post-metadata">

**Author:** ![ffirg](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ffirg/32/10029_2.png) [@ffirg](https://forum.ansible.com/u/ffirg)\
**Post date:** [July 23, 2020, 6:05pm UTC](https://forum.ansible.com/t/playboox-only-runs-the-second-time/33456/2 "2020-07-23T18:05:18Z")

</div>

Hi Robert

This doesn’t make a whole lot of sense why this would fail and then work. Definitely being applied to the SAME host on each run?  
I suggest you post your whole playbook(s) here as there’s something else going on outside the mentioned failing task I suspect.

As a good measure I would also include something like:

```auto
- name: Make sure psycopg2 is installed
  pip:
    name: psycopg2
    state: present

```

```auto
before you need it to ensure that base is covered as well.

```

```auto
Phil.

```
