Files
cmoa_agent_installer_ansible/roles/host/tasks/cmoa.yaml
2023-07-17 11:54:36 +09:00

11 lines
666 B
YAML

---
- name: host insert
shell: |
PG=$(kubectl get po -n imxc | grep postgres | awk '{print $1}')
for ip in {{ groups['containerd'] | map('extract', hostvars, ['ansible_host']) | union(groups['docker'] | map('extract', hostvars, ['ansible_host'])) | union(groups['crio'] | map('extract', hostvars, ['ansible_host'])) }}; do
ip_formatted=$(echo "$ip" | sed -e 's/[][]//g' -e 's/,//g')
kubectl exec -it -n imxc $PG -- psql -U admin postgresdb --command="INSERT INTO auth_resource3 VALUES (nextval('hibernate_sequence'), 'host|$ip_formatted:9100', false, null);"
done
when: inventory_hostname == groups['cmoa_master'][0]
ignore_errors: yes