# Errors when running ansible-playbook certbot.yml

**URL:** <https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666>\
**Category:** Primero IMS\
**Tags:** v2-0\
**Created:** [March 1, 2023, 9:41pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666 "2023-03-01T21:41:03Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![operations](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/o/b487fb/32.png) [@operations](https://support.primero.org/forum/u/operations)\
**Post date:** [March 1, 2023, 9:41pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/1 "2023-03-01T21:41:03Z")

</div>

Please Help. Thanks in Advance.

Please note: we are using the [GitHub - primeroIMS/primero: Primero is an application designed to help child protection workers and social workers in humanitarian and development contexts manage data on vulnerable children and survivors of violence. Please carefully read our LICENSE. If you would like access to the CPIMS+ and GBVIMS+ configurations, please contact: childprotectioninnovation@gmail.com · GitHub](https://github.com/primeroIMS/primero.git) [master branch]

Our DNS records are pointing to this Ubuntu server public IP. And if we install a webserver on the host itself, we were able to reach and was able to run lets encrypt to make it https. But for Primero communication to the docker instance is not happening. And we are getting Connection refused error.

When running the last command ansible-playbook certbot.yml.

**Following documentation was referred for doing the install on the Ubuntu server 20.04**

> <https://github.com/primeroIMS/primero/blob/master/ansible/README.md>

> [@Self Hosting Primero v2 - Installation](https://support.primero.org/forum/t/self-hosting-primero-v2-installation/434):
>
> So maybe you have read the [programmatic guidance](https://support.primero.org/forum/t/self-hosting-primero-v2-programme-guidance/503) for self hosting, self hosting [set up and background info](https://support.primero.org/forum/t/self-hosting-primero-v2-background-and-set-up/429), [the hosting requirements checklist](https://docs.google.com/document/d/1nXT2SFFLYIEXZh-bb5C2T452K8xldZAWG_kfXXVSa_Q/edit), you have completed all the [security tasks](https://support.primero.org/forum/t/how-to-security-harden-a-server/428), you have reviewed the [Tier 4 Deployment Workplan](https://docs.google.com/document/d/1BFkifvpZ_zUvHVLJRr7wUlj2secIopt0KF2VHmR6mPI/edit?usp=sharing), you have hired world class dev ops engineers/system admins and topped your bank account up to overflowing. Looks like you may be ready to self host! Target Install Ubuntu 20.04 LTS and upgrade the target machine if you have not already done so: sudo apt-get …

**We are getting following errors:**

PLAY [[protect.kinshipunited.org](http://protect.kinshipunited.org)] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK [Gathering Facts] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [[protect.kinshipunited.org](http://protect.kinshipunited.org)]

TASK [primero-certbot : create the /srv/primero/bin directory] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [[protect.kinshipunited.org](http://protect.kinshipunited.org)]

TASK [primero-certbot : copy the certbot binary to /srv/primero/bin/certbot] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [[protect.kinshipunited.org](http://protect.kinshipunited.org)]

TASK [primero-certbot : create the /srv/primero/bin/run-certbot.sh script] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [[protect.kinshipunited.org](http://protect.kinshipunited.org)]

TASK [primero-certbot : run certbot] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
fatal: [[protect.kinshipunited.org](http://protect.kinshipunited.org)]: FAILED! =\> changed=true  
cmd:

- /srv/primero/bin/run-certbot.sh  
delta: ‘0:00:04.039422’  
end: ‘2023-03-01 21:15:07.741754’  
msg: non-zero return code  
rc: 1  
start: ‘2023-03-01 21:15:03.702332’  
stderr: |-
  - exec /srv/primero/bin/certbot -d [protect.kinshipunited.org](http://protect.kinshipunited.org) --cert-name primero -m @.org -p primero  
Saving debug log to /var/log/letsencrypt/letsencrypt.log  
Plugins selected: Authenticator webroot, Installer None  
Performing the following challenges:  
http-01 challenge for [protect.kinshipunited.org](http://protect.kinshipunited.org)  
Using the webroot path /usr/share/nginx/html for all unmatched domains.  
Waiting for verification…  
Challenge failed for domain [protect.kinshipunited.org](http://protect.kinshipunited.org)  
http-01 challenge for [protect.kinshipunited.org](http://protect.kinshipunited.org)  
Cleaning up challenges  
Some challenges have failed.  
Traceback (most recent call last):  
File “/srv/primero/bin/certbot”, line 141, in   
code = \_main(sys.argv)  
File “/srv/primero/bin/certbot”, line 128, in \_main  
\_check\_call(command)  
File “/srv/primero/bin/certbot”, line 26, in \_check\_call  
subprocess.check\_call(args, \*popenargs, \*\*kwargs)  
File “/usr/lib/python3.8/subprocess.py”, line 364, in check\_call  
raise CalledProcessError(retcode, cmd)  
subprocess.CalledProcessError: Command ‘[‘docker’, ‘run’, ‘–rm’, ‘–interactive’, ‘–volume’, ‘primero\_certbot\_certificates:/etc/letsencrypt’, ‘–volume’, ‘primero\_certbot\_challenges:/usr/share/nginx/html/.well-known/acme-challenge’, ‘–volume’, ‘/tmp/tmpruuwzzdp:/tmp/deploy-hook-dir’, ‘certbot/certbot:v1.11.0’, ‘certonly’, ‘–non-interactive’, ‘–domain’, ‘[protect.kinshipunited.org](http://protect.kinshipunited.org)’, ‘–cert-name’, ‘primero’, ‘–email’, ‘@.org’, ‘–agree-tos’, ‘–rsa-key-size’, ‘2048’, ‘–deploy-hook’, ‘touch /tmp/deploy-hook-dir/renewed && chmod a+r -R /etc/letsencrypt/live && chmod a+r -R /etc/letsencrypt/archive’, ‘–webroot’, ‘–webroot-path’, ‘/usr/share/nginx/html’]’ returned non-zero exit status 1.  
stderr\_lines:   
stdout: |-  
Requesting a certificate for [protect.kinshipunited.org](http://protect.kinshipunited.org)  
IMPORTANT NOTES:

  - The following errors were reported by the server:

  - docker run --rm --interactive --volume primero\_certbot\_certificates:/etc/letsencrypt --volume primero\_certbot\_challenges:/usr/share/nginx/html/.well-known/acme-challenge --volume /tmp/tmpruuwzzdp:/tmp/deploy-hook-dir certbot/certbot:v1.11.0 certonly --non-interactive --domain [protect.kinshipunited.org](http://protect.kinshipunited.org) --cert-name primero --email @.org --agree-tos --rsa-key-size 2048 --deploy-hook ‘touch /tmp/deploy-hook-dir/renewed && chmod a+r -R /etc/letsencrypt/live && chmod a+r -R /etc/letsencrypt/archive’ --webroot --webroot-path /usr/share/nginx/html  
stdout\_lines: 

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
[protect.kinshipunited.org](http://protect.kinshipunited.org) : ok=4 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

**providing config details:**

/primero/ansible/inventory/inventory.yml

all:  
hosts:  
[protect.kinshipunited.org](http://protect.kinshipunited.org):  
ansible\_user: ‘kinship’  
primero\_host: ‘[protect.kinshipunited.org](http://protect.kinshipunited.org)’  
primero\_tag: ‘latest’

# As of Primero v2.5, the default Docker deployed PostgreSQL is 10.22.

# If you want to run Primero with a different version of PostgreSQL,

# set primero\_postgres\_version to either ‘11’ or ‘14’.

# NOTE: YOU NEED TO PERFORM A DATA MIGRATION BEFORE CHANGING POSTGRES VERSIONS!!!

# primero\_postgres\_version: ‘14’

locale\_all: ‘en,fr,ar’  
always\_pull: true,

# These 3 variables are used to drive the build task.

# Can be omitted if pulling images from Dockerhub

primero\_repo\_branch: ‘master’  
build\_docker\_tag: ‘latest’  
build\_docker\_container\_registry: ‘’

# If you want to seed from a private configuration repo

# primero\_configuration\_repo: ‘git@bitbucket.org:quoin/primero-x-configuration.git’

primero\_configuration\_repo\_branch: ‘master’  
primero\_configuration\_path: ‘directory/of/config/loader/script’  
use\_lets\_encrypt: ‘true’  
use\_external\_certs: ‘false’

# The other certbot/lets\_encrypt variables are optional. Include only if using Let’s Encrypt

certbot\_domain:

- ‘{{ primero\_host }}’  
certbot\_email: ‘removed@actual-domain-removed’  
lets\_encrypt\_domain: ‘{{ primero\_host }}’  
lets\_encrypt\_email: ‘{{ certbot\_email }}’

# Different for self-signed certs

nginx\_ssl\_cert\_path: ‘/etc/letsencrypt/live/primero/fullchain.pem’  
nginx\_ssl\_key\_path: ‘/etc/letsencrypt/live/primero/privkey.pem’

# nginx\_ssl\_cert\_path: ‘/home/kinship/my-external-certs/kust.crt’

# nginx\_ssl\_key\_path: ‘/home/kinship/my-external-certs/kupr.key’

# Optionally parametrize Primero containers with other environment attributes.

# Do not use this dictionary for secrets!!!

environment\_variables:  
PRIMERO\_DEFAULT\_USERS: ‘true’ # Seed default users when using the managed Primero SaaS configs

# LOCALE\_DEFAULT: ‘ar’ # Optionally override English as the default locale.

* * *

/primero/ansible/secrets.yml  
primero\_secret\_key\_base: ‘---------dummy-value01-----------’  
primero\_message\_secret: ‘---------dummy-value02-----------’  
postgres\_password: ‘---------dummy-value03-----------’  
devise\_secret\_key: ‘---------dummy-value04-----------’  
devise\_jwt\_secret\_key: ‘---------dummy-value05-----------’

---

<div class="post-metadata">

**Author:** ![irlawrence](https://support.primero.org/forum/user_avatar/support.primero.org/irlawrence/32/8_2.png) [@irlawrence](https://support.primero.org/forum/u/irlawrence)\
**Post date:** [March 2, 2023, 5:23pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/3 "2023-03-02T17:23:08Z")

</div>

You have removed the webserver you installed on the host correct?

---

<div class="post-metadata">

**Author:** ![operations](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/o/b487fb/32.png) [@operations](https://support.primero.org/forum/u/operations)\
**Post date:** [March 2, 2023, 5:57pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/4 "2023-03-02T17:57:18Z")

</div>

Yes.

In the second scenario: We modified the inventory file to refer to external certs (with our own certificate and key), instead of letsencrypt; but it doesn’t seem to work either.

Is there any other documentation that I can refer that supports Ubuntu 20.04 version. Other than the one which I was looking at:

I’m ready to discard the instance that we have so far and will start over; based on your suggestions. Thank you.

> <https://github.com/primeroIMS/primero/blob/master/ansible/README.md>

> [@Self Hosting Primero v2 - Installation](https://support.primero.org/forum/t/self-hosting-primero-v2-installation/434):
>
> So maybe you have read the [programmatic guidance](https://support.primero.org/forum/t/self-hosting-primero-v2-programme-guidance/503) for self hosting, self hosting [set up and background info](https://support.primero.org/forum/t/self-hosting-primero-v2-background-and-set-up/429), [the hosting requirements checklist](https://docs.google.com/document/d/1nXT2SFFLYIEXZh-bb5C2T452K8xldZAWG_kfXXVSa_Q/edit), you have completed all the [security tasks](https://support.primero.org/forum/t/how-to-security-harden-a-server/428), you have reviewed the [Tier 4 Deployment Workplan](https://docs.google.com/document/d/1BFkifvpZ_zUvHVLJRr7wUlj2secIopt0KF2VHmR6mPI/edit?usp=sharing), you have hired world class dev ops engineers/system admins and topped your bank account up to overflowing. Looks like you may be ready to self host! Target Install Ubuntu 20.04 LTS and upgrade the target machine if you have not already done so: sudo apt-get …

---

<div class="post-metadata">

**Author:** ![operations](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/o/b487fb/32.png) [@operations](https://support.primero.org/forum/u/operations)\
**Post date:** [March 2, 2023, 7:09pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/5 "2023-03-02T19:09:26Z")

</div>

Some more information:

But here are the problems that we have. When letsencrypt is trying to validate the container through the DNS. It cannot even reach the container and it’s contents.

For example: Following file/directory in DOCKER doesn’t even exist  
/.well-known/acme-challenge/jKdGBJqIKQcvT6KHg-qs9VMMg3\_B6ytfP1ipKWAwT1E

And when I connected to the container and created a simple file; that file cannot be accessed as well. The error message that I’m getting from the browser is “ERR\_CONNECTION\_REFUSED”

Used this to connect to the NGINX container; which was created as part of ansible:  
sudo -s  
docker ps  
docker exec -it sh

 ![image](https://support.primero.org/uploads/primero/original/1X/2d98f92932efceb804376a6d3a6c73bd153cdf71.png)

---

<div class="post-metadata">

**Author:** ![irlawrence](https://support.primero.org/forum/user_avatar/support.primero.org/irlawrence/32/8_2.png) [@irlawrence](https://support.primero.org/forum/u/irlawrence)\
**Post date:** [March 2, 2023, 10:42pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/6 "2023-03-02T22:42:47Z")

</div>

It looks like something may be messed up with ther nginx container

---

<div class="post-metadata">

**Author:** ![operations](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/o/b487fb/32.png) [@operations](https://support.primero.org/forum/u/operations)\
**Post date:** [March 3, 2023, 2:37pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/7 "2023-03-03T14:37:50Z")

</div>

That’s right. Certbot is trying to validate with nginx container with following location.  
/usr/share/nginx/html/.well-known/acme-challenge

Can you help me understand where from “acme” or “acme-challenge” is coming from?

---

<div class="post-metadata">

**Author:** ![irlawrence](https://support.primero.org/forum/user_avatar/support.primero.org/irlawrence/32/8_2.png) [@irlawrence](https://support.primero.org/forum/u/irlawrence)\
**Post date:** [March 7, 2023, 7:09pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/8 "2023-03-07T19:09:57Z")

</div>

> [@operations](#):
>
> acme-challenge

It [comes from Lets Encrypt](https://letsencrypt.org/docs/challenge-types/) when you run it

---

<div class="post-metadata">

**Author:** ![operations](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/o/b487fb/32.png) [@operations](https://support.primero.org/forum/u/operations)\
**Post date:** [March 21, 2023, 4:12pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/9 "2023-03-21T16:12:11Z")

</div>

Hello,

What is the default user id and password to use after getting the login page? Following username and password did not work.  
UserName: primero  
Password: primer0!

Please note that deployment was done with ansible.

Thank you.

---

<div class="post-metadata">

**Author:** ![irlawrence](https://support.primero.org/forum/user_avatar/support.primero.org/irlawrence/32/8_2.png) [@irlawrence](https://support.primero.org/forum/u/irlawrence)\
**Post date:** [March 21, 2023, 4:36pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/10 "2023-03-21T16:36:27Z")

</div>

You can create one in the application container using something like:

`docker exec -it <container_name> -- bash`

then

```auto
rails -c
unicef = Agency.find_by(agency_code: 'UNICEF')
role = Role.find_by_name('Superuser')

User.create_or_update!({
'user_name' => 'a@b.com',
'password' => 'whatever_you_want',
'password_confirmation' => 'whatever_you_want',
'full_name' => 'A Name',
'email' => 'a@b.com',
'disabled' => 'false',
'agency_id' => unicef.id,
'role_id' => role.id,
'user_groups' => UserGroup.all,
'locale' => Primero::Application::LOCALE_ENGLISH
	})

```

Which adds an English speaking superuser into all groups in the UNICEF agency

---

<div class="post-metadata">

**Author:** ![operations](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/o/b487fb/32.png) [@operations](https://support.primero.org/forum/u/operations)\
**Post date:** [March 21, 2023, 5:45pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/11 "2023-03-21T17:45:27Z")

</div>

When I connect to the docker container and run “railc -c”; I’m getting following error. Please suggest.

docker exec -it 1ab4d9e812f9 sh

/srv/primero/application $ rails -c  
Rspec not installed–omitting tasks  
rails aborted!  
Don’t know how to build task ‘default’ (See the list of available tasks with `rails --tasks`)

(See full trace by running task with --trace).

Some additional information::

/srv/primero/application $ rails about  
Rspec not installed–omitting tasks  
D, [2023-03-21T18:09:10.315883 #63] DEBUG – : (0.3ms) SELECT 1;  
I, [2023-03-21T18:09:10.317677 #63] INFO – : Setting up PeriodicJobs  
D, [2023-03-21T18:09:10.337422 #63] DEBUG – : Delayed::Backend::ActiveRecord::Job Exists? (0.7ms) SELECT 1 AS one FROM “delayed\_jobs” WHERE (handler LIKE ‘%job\_class: ArchiveBulkExports%’) LIMIT $1 [[“LIMIT”, 1]]  
D, [2023-03-21T18:09:10.341865 #63] DEBUG – : Delayed::Backend::ActiveRecord::Job Exists? (0.6ms) SELECT 1 AS one FROM “delayed\_jobs” WHERE (handler LIKE ‘%job\_class: OptimizeSolr%’) LIMIT $1 [[“LIMIT”, 1]]  
D, [2023-03-21T18:09:10.343499 #63] DEBUG – : Delayed::Backend::ActiveRecord::Job Exists? (0.6ms) SELECT 1 AS one FROM “delayed\_jobs” WHERE (handler LIKE ‘%job\_class: RecalculateAge%’) LIMIT $1 [[“LIMIT”, 1]]  
D, [2023-03-21T18:09:10.802067 #63] DEBUG – : (1.3ms) SELECT “schema\_migrations”.“version” FROM “schema\_migrations” ORDER BY “schema\_migrations”.“version” ASC  
About your application’s environment  
Rails version 6.1.7.1  
Ruby version ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86\_64-linux-musl]  
RubyGems version 3.1.6  
Rack version 2.2.6.2  
Middleware ActionDispatch::HostAuthorization, ActionDispatch::SSL, Rack::Sendfile, ActionDispatch::Executor, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, ActionDispatch::RemoteIp, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::ActionableExceptions, ActionDispatch::Callbacks, ActionDispatch::Cookies, ActionDispatch::ContentSecurityPolicy::Middleware, ActionDispatch::PermissionsPolicy::Middleware, Rack::Head, Rack::ConditionalGet, Rack::ETag, Rack::TempfileReaper, WwwAuthenticate, Warden::Manager, Rack::Deflater, JwtTokenSetter, Warden::JWTAuth::Middleware, Rack::Attack  
Application root /srv/primero/application  
Environment production  
Database adapter postgresql  
Database schema version 20220328075916

---

<div class="post-metadata">

**Author:** ![irlawrence](https://support.primero.org/forum/user_avatar/support.primero.org/irlawrence/32/8_2.png) [@irlawrence](https://support.primero.org/forum/u/irlawrence)\
**Post date:** [March 21, 2023, 6:34pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/12 "2023-03-21T18:34:10Z")

</div>

There is a difference between doing

```auto
docker exec -it 1ab4d9e812f9 sh
rails c

```

and doing this (which should work)

```auto
docker exec -it primero_application_1 bash
rails c

```

---

<div class="post-metadata">

**Author:** ![operations](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/o/b487fb/32.png) [@operations](https://support.primero.org/forum/u/operations)\
**Post date:** [March 21, 2023, 7:45pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/13 "2023-03-21T19:45:36Z")

</div>

Thank you. I was able to connect and run the commands you gave. But getting following error message “NoMethodError (undefined method `id’ for nil:NilClass)”

irb(main):001:0\> unicef=Agency.find\_by(agency\_code: ‘UNICEF’)  
D, [2023-03-21T19:32:06.354513 #119] DEBUG – : Agency Load (1.3ms) SELECT “agencies”.\* FROM “agencies” WHERE “agencies”.“agency\_code” = $1 LIMIT $2 [[“agency\_code”, “UNICEF”], [“LIMIT”, 1]]  
=\> nil  
irb(main):002:0\> role=Role.find\_by\_name(‘Superuser’)  
D, [2023-03-21T19:32:07.338724 #119] DEBUG – : Role Load (1.0ms) SELECT “roles”.\* FROM “roles” WHERE “roles”.“name” = $1 LIMIT $2 [[“name”, “Superuser”], [“LIMIT”, 1]]  
=\> nil  
irb(main):003:0\> User.c’password\_confirmation’ =\> ‘temp-password-01’,  
‘full\_name’ =\> ‘kinship admin’,  
‘email’ =\> ‘email@temp-email.org’,  
‘disabled’ =\> ‘false’,  
‘agency\_id’ =\> unicef.id,  
‘role\_id’ =\> role.id,  
‘user\_groups’ =\> UserGroup.all,  
‘locale’ =\> Primero::Application::LOCALE\_ENGLISH  
irb(main):003:2\* User.create\_or\_update!({  
irb(main):004:2\* ‘user\_name’ =\> ‘operations’,  
irb(main):005:2\* ‘password’ =\> ‘temp-password-01’,  
irb(main):006:2\* ‘password\_confirmation’ =\> ‘temp-password-01’,  
irb(main):007:2\* ‘full\_name’ =\> ‘kinship admin’,  
irb(main):008:2\* ‘email’ =\> ‘email@temp-email.org’,  
irb(main):009:2\* ‘disabled’ =\> ‘false’,  
irb(main):010:2\* ‘agency\_id’ =\> unicef.id,  
irb(main):011:2\* ‘role\_id’ =\> role.id,  
irb(main):012:2\* ‘user\_groups’ =\> UserGroup.all,  
irb(main):013:2\* ‘locale’ =\> Primero::Application::LOCALE\_ENGLISH  
irb(main):014:0\> })  
Traceback (most recent call last):  
1: from (irb):10  
NoMethodError (undefined method `id’ for nil:NilClass)

irb(main):015:0\>

---

<div class="post-metadata">

**Author:** ![operations](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/o/b487fb/32.png) [@operations](https://support.primero.org/forum/u/operations)\
**Post date:** [March 21, 2023, 8:08pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/14 "2023-03-21T20:08:43Z")

</div>

Since we are initially running unicef= and role= with some values. I changed User.create\_or\_update! to reflect with those specific names instead of .id. Now I’m getting this error::  
NameError (undefined local variable or method `userGroup’ for main:Object)

::::: details below ::::

irb(main):004:2\* User.create\_or\_update!({  
irb(main):005:2\* ‘user\_name’ =\> ‘operations’,  
irb(main):006:2\* ‘password’ =\> ‘temp-password-01’,  
irb(main):007:2\* ‘password\_confirmation’ =\> ‘temp-password-01’,  
irb(main):008:2\* ‘full\_name’ =\> ‘kinship admin’,  
irb(main):009:2\* ‘email’ =\> ‘email@temp-email.org’,  
irb(main):010:2\* ‘disabled’ =\> ‘false’,  
irb(main):011:2\* ‘agency\_id’ =\> unicef,  
irb(main):012:2\* ‘role\_id’ =\> role,  
irb(main):013:2\* ‘user\_groups’ =\> userGroup.all,  
irb(main):014:2\* ‘locale’ =\> Primero::Application::LOCALE\_ENGLISH  
irb(main):015:0\> })  
Traceback (most recent call last):  
1: from (irb):12  
NameError (undefined local variable or method `userGroup’ for main:Object)  
irb(main):016:0\>

---

<div class="post-metadata">

**Author:** ![irlawrence](https://support.primero.org/forum/user_avatar/support.primero.org/irlawrence/32/8_2.png) [@irlawrence](https://support.primero.org/forum/u/irlawrence)\
**Post date:** [March 22, 2023, 6:43pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/15 "2023-03-22T18:43:39Z")

</div>

So hard coding things is not going to work as the issue is deeper. You need to find out why the command you ran to SELECT all agencies on your system returned nil

> [@operations](#):
>
> irb(main):001:0\> unicef=Agency.find\_by(agency\_code: ‘UNICEF’)  
> D, [2023-03-21T19:32:06.354513 #119] DEBUG – : Agency Load (1.3ms) SELECT “agencies”.\* FROM “agencies” WHERE “agencies”.“agency\_code” = $1 LIMIT $2 [[“agency\_code”, “UNICEF”], [“LIMIT”, 1]]  
> =\> nil

on my test system it returns this →

```auto
SELECT "agencies".* FROM "agencies" WHERE "agencies"."agency_code" = $1 LIMIT $2 [["agency_code", "UNICEF"], ["LIMIT", 1]]
=> #<Agency id: 1, unique_id: "UNICEF", agency_code: "UNICEF", order: 0, name_i18n: {"en"=>"UNICEF", "pt-BR"=>"UNICEF"}, description_i18n: nil, telephone: nil, services: [], logo_enabled: false, disabled: false, pdf_logo_option: false, exclude_agency_from_lookups: false, terms_of_use_enabled: false, created_at: "2021-09-27 21:07:10", updated_at: "2021-09-27 21:39:41", logo_full_base64: nil, logo_full_file_name: nil, logo_icon_base64: nil, logo_icon_file_name: nil, terms_of_use_base64: nil, terms_of_use_file_name: nil>

```

so basically the database looks empty. Did the seed finish correctly?

---

<div class="post-metadata">

**Author:** ![irlawrence](https://support.primero.org/forum/user_avatar/support.primero.org/irlawrence/32/8_2.png) [@irlawrence](https://support.primero.org/forum/u/irlawrence)\
**Post date:** [March 22, 2023, 6:55pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/16 "2023-03-22T18:55:19Z")

</div>

You can check the database by exec’ing into the postgres container and running psql

```auto
docker exec -it primero_postgres_1 bash
bash-4.4# psql -U primero

```

---

<div class="post-metadata">

**Author:** ![operations](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/o/b487fb/32.png) [@operations](https://support.primero.org/forum/u/operations)\
**Post date:** [March 22, 2023, 7:49pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/17 "2023-03-22T19:49:41Z")

</div>

From the “primero\_production” database I was able to see tables; and within the agencies table, columns are also shown.  
You are right, I’m not seeing any data within the columns.

I actually rerun all the ansible scripts again; and did not receive any errors. And still don’t see data.

Since the docker is running now. Is there a way that I can run the seed within the docker container?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![operations](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/o/b487fb/32.png) [@operations](https://support.primero.org/forum/u/operations)\
**Post date:** [March 22, 2023, 8:47pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/18 "2023-03-22T20:47:15Z")

</div>

Hi irlawrence,

Thank you for the suggestion. I connected to the container and ran these commands; and it created the data. And I was able to login to the application now.

docker exec -it primero\_application\_1 bash  
rails c

rails db:create  
rails db:migrate  
rails db:seed

Thank you so much.

---

<div class="post-metadata">

**Author:** ![irlawrence](https://support.primero.org/forum/user_avatar/support.primero.org/irlawrence/32/8_2.png) [@irlawrence](https://support.primero.org/forum/u/irlawrence)\
**Post date:** [March 22, 2023, 8:55pm UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/19 "2023-03-22T20:55:24Z")

</div>

Awesome! Hope you enjoy it 😄

---

<div class="post-metadata">

**Author:** ![srinivasa.puneeth](https://support.primero.org/forum/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@srinivasa.puneeth](https://support.primero.org/forum/u/srinivasa.puneeth)\
**Post date:** [June 16, 2023, 5:54am UTC](https://support.primero.org/forum/t/errors-when-running-ansible-playbook-certbot-yml/666/20 "2023-06-16T05:54:16Z")

</div>

Hey @operations, I am facing the same error when running “ansible-playbook certbot.yml”. I went through the whole conversation here on this topic but I did not find a solution on how did you resolve this issue.

we are using the: [https://github.com/primeroIMS/primero](https://github.com/primeroIMS/primero) [developementV2 branch]

DNS records are pointing to our Ubuntu public IP and I am getting the same error as you did when I am running the last command from the self-hosting V2 Primero documentation: ansible-playbook certbot.yml.

Can you or @irlawrence help me out here? Thanks in advance.
