ansible-collections / ansible-consul

:satellite: Ansible role for Hashicorp Consul clusters
https://galaxy.ansible.com/ansible-community/consul/
BSD 2-Clause "Simplified" License
452 stars 313 forks source link

dnsmasq: update the "Disable systemd-resolved" tasks #519

Closed vitabaks closed 1 year ago

vitabaks commented 1 year ago

Fixed:

ERROR: src file does not exist

TASK [consul : Disable systemd-resolved service] ****************************************************************************************************************************************************************
changed: [172.31.15.62]
changed: [3.223.140.234]
changed: [172.31.5.27]

TASK [consul : Check if resolv.conf is pointing to systemd-resolved] ********************************************************************************************************************************************
ok: [172.31.15.62]
ok: [3.223.140.234]
ok: [172.31.5.27]

TASK [consul : Remove resolv.conf association with systemd-resolved] ********************************************************************************************************************************************
fatal: [3.223.140.234]: FAILED! => {"changed": false, "gid": 0, "group": "root", "mode": "0777", "msg": "src file does not exist, use \"force=yes\" if you really want to create the link: /run/resolvconf/resolv.conf", "owner": "root", "path": "/etc/resolv.conf", "size": 39, "src": "/run/resolvconf/resolv.conf", "state": "link", "uid": 0}
fatal: [172.31.15.62]: FAILED! => {"changed": false, "gid": 0, "group": "root", "mode": "0777", "msg": "src file does not exist, use \"force=yes\" if you really want to create the link: /run/resolvconf/resolv.conf", "owner": "root", "path": "/etc/resolv.conf", "size": 39, "src": "/run/resolvconf/resolv.conf", "state": "link", "uid": 0}
fatal: [172.31.5.27]: FAILED! => {"changed": false, "gid": 0, "group": "root", "mode": "0777", "msg": "src file does not exist, use \"force=yes\" if you really want to create the link: /run/resolvconf/resolv.conf", "owner": "root", "path": "/etc/resolv.conf", "size": 39, "src": "/run/resolvconf/resolv.conf", "state": "link", "uid": 0}

NO MORE HOSTS LEFT **********************************************************************************************************************************************************************************************

PLAY RECAP ******************************************************************************************************************************************************************************************************
172.31.15.62               : ok=48   changed=19   unreachable=0    failed=1    skipped=68   rescued=0    ignored=0   
172.31.5.27                : ok=54   changed=21   unreachable=0    failed=1    skipped=69   rescued=0    ignored=1   
3.223.140.234              : ok=48   changed=19   unreachable=0    failed=1    skipped=68   rescued=0    ignored=0   
localhost                  : ok=1    changed=0    unreachable=0    failed=0    skipped=2    rescued=0    ignored=0   

ubuntu@ip-172-31-5-27:~/postgresql_cluster$ ls -la /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Dec  1 11:06 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
ubuntu@ip-172-31-5-27:~/postgresql_cluster$ ls -la /run/resolvconf/resolv.conf
ls: cannot access '/run/resolvconf/resolv.conf': No such file or directory

Test result:

ubuntu@source-pgnode02:~$ cat /etc/dnsmasq.d/10-consul
server=/consul/127.0.0.1#8600
server=8.8.8.8
server=8.8.4.4
ubuntu@source-pgnode02:~$ ls -la /etc/resolv.conf 
-rw-r--r-- 1 root root 21 Jan  4 19:22 /etc/resolv.conf
ubuntu@source-pgnode02:~$ 
ubuntu@source-pgnode02:~$ cat /etc/resolv.conf 
nameserver 127.0.0.1
ubuntu@source-pgnode02:~$ 
ubuntu@source-pgnode02:~$ dig +short master.patroni.service.consul SRV
1 1 6432 source-pgnode01.node.us-east-1d.consul.
vitabaks commented 1 year ago

Error for RedHat family version 9

FAILED! => {"changed": false, "msg": "Could not find the requested service systemd-resolved: host"}

fixed: https://github.com/ansible-community/ansible-consul/pull/519/commits/f12246b50d4ba356117b7275a7b3a99ba8ec6f23

vitabaks commented 1 year ago

Ok, this PR is starting to look much better. However, I'm a bit concerned about the lack of a molecule test. Is this something that can easily be tested in a Docker container? If not, can you test it locally on whatever platforms you have access to?

this has been tested as part of the project https://github.com/vitabaks/postgresql_cluster

I didn't do any molecule tests as part of this PR.

nre-ableton commented 1 year ago

@vitabaks Ok, this PR looks good. :+1: Could you please run a quick test with the latest changes before I merge?

vitabaks commented 1 year ago

Could you please run a quick test with the latest changes before I merge?

@nre-ableton Ok, here are the test results on my repository

image

details: https://github.com/vitabaks/postgresql_cluster/actions/runs/4303678548

nre-ableton commented 1 year ago

@vitabaks Great! Unfortunately some linter tasks are failing on our end. :disappointed: I'll investigate those this afternoon and try to come up with a fix.

nre-ableton commented 1 year ago

@vitabaks thanks again for your contribution!