From 7d6744837b9d31bfae2e85063d47467ef1a3bbfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B3=80=EC=A0=95=ED=9B=88?= Date: Wed, 12 Jul 2023 14:02:41 +0900 Subject: [PATCH] =?UTF-8?q?gather=5Ffacts=20=EC=A0=9C=EA=B1=B0=20=EB=B0=8F?= =?UTF-8?q?=20=EC=A0=9C=EA=B1=B0=EC=97=90=20=EB=94=B0=EB=A5=B8=20script=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roles/jspd/tasks/cmoa.yaml | 2 +- roles/jspd/tasks/containerd.yaml | 4 ++-- roles/jspd/tasks/delete.yaml | 2 +- roles/jspd/tasks/docker.yaml | 4 ++-- roles/jspd/tasks/podman.yaml | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/roles/jspd/tasks/cmoa.yaml b/roles/jspd/tasks/cmoa.yaml index 82d366e..97e84e3 100644 --- a/roles/jspd/tasks/cmoa.yaml +++ b/roles/jspd/tasks/cmoa.yaml @@ -2,7 +2,7 @@ - name: host insert shell: | PG=$(kubectl get po -n imxc | grep postgres | awk '{print $1}') - for ip in {{ groups['containerd'] | union(groups['docker']) | union(groups['crio']) }}; do + 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 diff --git a/roles/jspd/tasks/containerd.yaml b/roles/jspd/tasks/containerd.yaml index cf42aec..3e6faab 100644 --- a/roles/jspd/tasks/containerd.yaml +++ b/roles/jspd/tasks/containerd.yaml @@ -3,13 +3,13 @@ lineinfile: path: /root/host-agent/nerdctl-host/metric-agent.yml regexp: 'targets' - line: " - targets: ['{{ ansible_default_ipv4.address }}:9100']" + line: " - targets: ['{{ ip }}:9100']" when: - inventory_hostname in groups['containerd'] - name: host agent install setting [2] - containerd shell: | - sed -i "s/10.10.34.142/{{ hostvars[groups['cmoa-master'][0]]['ansible_default_ipv4']['address'] }}/" /root/host-agent/nerdctl-host/setup_nerdctl.sh + sed -i "s/10.10.34.142/{{ hostvars[groups['cmoa-master'][0]]['ip'] }}/" /root/host-agent/nerdctl-host/setup_nerdctl.sh sed -i "s/rel3.4.6/rel{{ VERSION }}/" /root/host-agent/nerdctl-host/setup_nerdctl.sh when: - inventory_hostname in groups['containerd'] diff --git a/roles/jspd/tasks/delete.yaml b/roles/jspd/tasks/delete.yaml index faa8e8e..f37bd2b 100644 --- a/roles/jspd/tasks/delete.yaml +++ b/roles/jspd/tasks/delete.yaml @@ -13,7 +13,7 @@ - delete_enabled - inventory_hostname in groups['containerd'] -- name: agent conatiner delete - podman.yaml +- name: agent conatiner delete shell: /root/host-agent/podman-host/stop.sh ignore_errors: true when: diff --git a/roles/jspd/tasks/docker.yaml b/roles/jspd/tasks/docker.yaml index 82cf757..333cae0 100644 --- a/roles/jspd/tasks/docker.yaml +++ b/roles/jspd/tasks/docker.yaml @@ -3,13 +3,13 @@ lineinfile: path: /root/host-agent/docker-host/metric-agent.yml regexp: 'targets' - line: " - targets: ['{{ ansible_default_ipv4.address }}:9100']" + line: " - targets: ['{{ ip }}:9100']" when: - inventory_hostname in groups['docker'] - name: host agent install setting [2] - docker shell: | - sed -i "s/10.10.34.142/{{ hostvars[groups['cmoa-master'][0]]['ansible_default_ipv4']['address'] }}/" /root/host-agent/docker-host/setup.sh + sed -i "s/10.10.34.142/{{ hostvars[groups['cmoa-master'][0]]['ip'] }}/" /root/host-agent/docker-host/setup.sh sed -i "s/rel3.4.6/rel{{ VERSION }}/" /root/host-agent/docker-host/setup.sh when: - inventory_hostname in groups['docker'] diff --git a/roles/jspd/tasks/podman.yaml b/roles/jspd/tasks/podman.yaml index 513aee8..6344ced 100644 --- a/roles/jspd/tasks/podman.yaml +++ b/roles/jspd/tasks/podman.yaml @@ -3,13 +3,13 @@ lineinfile: path: /root/host-agent/podman-host/metric-agent.yml regexp: 'targets' - line: " - targets: ['{{ ansible_default_ipv4.address }}:9100']" + line: " - targets: ['{{ ip }}:9100']" when: - inventory_hostname in groups['crio'] - name: host agent install setting [2] - crio shell: | - sed -i "s/10.10.34.142/{{ hostvars[groups['cmoa-master'][0]]['ansible_default_ipv4']['address'] }}/" /root/host-agent/podman-host/setup.sh + sed -i "s/10.10.34.142/{{ hostvars[groups['cmoa-master'][0]]['ip'] }}/" /root/host-agent/podman-host/setup.sh sed -i "s/rel3.4.6/rel{{ VERSION }}/" /root/host-agent/podman-host/setup.sh when: - inventory_hostname in groups['crio']