From 25f79483dbfdeaec3bf69c8a56275f058af8f229 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 12:39:34 +0000 Subject: [PATCH 01/49] Update ping/ping.yml --- ping/ping.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ping/ping.yml b/ping/ping.yml index 0130a92..ab9f8a4 100644 --- a/ping/ping.yml +++ b/ping/ping.yml @@ -2,5 +2,7 @@ - hosts: "{{ host }}" gather_facts: false + become = true + become_method = sudo tasks: - ping: \ No newline at end of file From 9287a7ab5f3e8010d642c949d8f83000420b4278 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 12:42:46 +0000 Subject: [PATCH 02/49] Update ping/ping.yml --- ping/ping.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ping/ping.yml b/ping/ping.yml index ab9f8a4..003309f 100644 --- a/ping/ping.yml +++ b/ping/ping.yml @@ -2,7 +2,7 @@ - hosts: "{{ host }}" gather_facts: false - become = true - become_method = sudo + become: yes + become_method: sudo tasks: - ping: \ No newline at end of file From 6ef847c9e0cbea38c822f6c5677093e85ff38bd4 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 12:51:31 +0000 Subject: [PATCH 03/49] Update ping/ping.yml --- ping/ping.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ping/ping.yml b/ping/ping.yml index 003309f..06a3649 100644 --- a/ping/ping.yml +++ b/ping/ping.yml @@ -1,7 +1,7 @@ --- - hosts: "{{ host }}" - gather_facts: false + gather_facts: true become: yes become_method: sudo tasks: From 79ba9f2f8f953079cf7578df71348967d3218ec9 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 12:53:34 +0000 Subject: [PATCH 04/49] Update ping/ping.yml --- ping/ping.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/ping/ping.yml b/ping/ping.yml index 06a3649..0f906d5 100644 --- a/ping/ping.yml +++ b/ping/ping.yml @@ -2,7 +2,5 @@ - hosts: "{{ host }}" gather_facts: true - become: yes - become_method: sudo tasks: - ping: \ No newline at end of file From f7960e892a5d10c74d8bf9427d0c81f1bc8f92e9 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 17:19:47 +0000 Subject: [PATCH 05/49] Add os/os-release.yml --- os/os-release.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 os/os-release.yml diff --git a/os/os-release.yml b/os/os-release.yml new file mode 100644 index 0000000..e69de29 From c7b5ee2ee4ae78b1abbcdcc69903d630385f759a Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 17:21:49 +0000 Subject: [PATCH 06/49] Update os/os-release.yml --- os/os-release.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/os/os-release.yml b/os/os-release.yml index e69de29..33cee3b 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -0,0 +1,9 @@ +--- +- hosts: "{{ host }}" + gather_facts: False + tasks: + - name: Check Dist Version + shell: cat /etc/os-release + register: response + + - debug: msg="{{ response.stdout }}" \ No newline at end of file From 9e29721612ba626a566bcec825a11ca5393efa06 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 17:28:26 +0000 Subject: [PATCH 07/49] Update os/os-release.yml --- os/os-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/os-release.yml b/os/os-release.yml index 33cee3b..656a93a 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -1,6 +1,6 @@ --- - hosts: "{{ host }}" - gather_facts: False + gather_facts: True tasks: - name: Check Dist Version shell: cat /etc/os-release From f8cefbfd9e03be8f1a241e2c3c3359749797391d Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 17:31:14 +0000 Subject: [PATCH 08/49] Update os/os-release.yml --- os/os-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/os-release.yml b/os/os-release.yml index 656a93a..2acf15c 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -6,4 +6,4 @@ shell: cat /etc/os-release register: response - - debug: msg="{{ response.stdout }}" \ No newline at end of file + - debug: msg="{{ response.stdout }}" | grep PRETTY_NAME \ No newline at end of file From e2b0e0166eba03ad96ba03d3498a0d11cf26f3a0 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 17:32:58 +0000 Subject: [PATCH 09/49] Update os/os-release.yml --- os/os-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/os-release.yml b/os/os-release.yml index 2acf15c..e942687 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -6,4 +6,4 @@ shell: cat /etc/os-release register: response - - debug: msg="{{ response.stdout }}" | grep PRETTY_NAME \ No newline at end of file + - debug: msg="{{ response.stdout | grep PRETTY_NAME }}" \ No newline at end of file From 2516d17ac233075b085543965a60d9a9a905b6e1 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 17:35:14 +0000 Subject: [PATCH 10/49] Update os/os-release.yml --- os/os-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/os-release.yml b/os/os-release.yml index e942687..656a93a 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -6,4 +6,4 @@ shell: cat /etc/os-release register: response - - debug: msg="{{ response.stdout | grep PRETTY_NAME }}" \ No newline at end of file + - debug: msg="{{ response.stdout }}" \ No newline at end of file From bc3bcbc7b24ff035db1ce7aa7bbeccfddeb0e76d Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 18:15:33 +0000 Subject: [PATCH 11/49] Update hosts --- hosts | 108 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 64 insertions(+), 44 deletions(-) diff --git a/hosts b/hosts index bf11b81..83249ab 100644 --- a/hosts +++ b/hosts @@ -1,15 +1,19 @@ [servers] -docker ansible_host=10.0.6.116 +[proxmox] mox1 ansible_host=mox1.verdnatura.es mox2 ansible_host=mox2.verdnatura.es mox3 ansible_host=mox3.verdnatura.es mox4 ansible_host=mox4.verdnatura.es mox5 ansible_host=mox5.verdnatura.es -ve3 ansible_host=ve3.verdnatura.es -ve4 ansible_host=ve4.verdnatura.es -ve5 ansible_host=ve5.verdnatura.es -vcenter ansible_host=vcenter.verdnatura.es +mox91 ansible_host=mox91.verdnatura.es +mox92 ansible_host=mox92.verdnatura.es +mox93 ansible_host=mox93.verdnatura.es +docker ansible_host=10.0.6.116 + + +[ilo] + mox1-ilo ansible_host=mox1-ilo.verdnatura.es mox2-ilo ansible_host=mox2-ilo.verdnatura.es mox3-ilo ansible_host=mox3-ilo.verdnatura.es @@ -18,17 +22,62 @@ mox5-ilo ansible_host=mox5-ilo.verdnatura.es ve3-ilo ansible_host=ve3-ilo.verdnatura.es ve4-ilo ansible_host=ve4-ilo.verdnatura.es ve5-ilo ansible_host=ve5-ilo.verdnatura.es -mox91 ansible_host=mox91.verdnatura.es -mox92 ansible_host=mox92.verdnatura.es -mox93 ansible_host=mox93.verdnatura.es + +[kubernetes] + +kube-master1 ansible_host=kube-master1.static.verdnatura.es +kube-master2 ansible_host=kube-master2.static.verdnatura.es +kube-master3 ansible_host=kube-master3.static.verdnatura.es +kube-worker1 ansible_host=kube-worker1.static.verdnatura.es +kube-worker2 ansible_host=kube-worker2.static.verdnatura.es +kube-worker3 ansible_host=kube-worker3.static.verdnatura.es +kube-worker4 ansible_host=kube-worker4.static.verdnatura.es +kube-proxy1 ansible_host=kube-proxy1.static.verdnatura.es +kube-proxy2 ansible_host=kube-proxy2.static.verdnatura.es +kube-helm ansible_host=kube-helm.static.verdnatura.es + +[swarm] + +swarm-mgr1 ansible_host=swarm-mgr1.static.verdnatura.es +swarm-mgr2 ansible_host=swarm-mgr2.static.verdnatura.es +swarm-mgr3 ansible_host=swarm-mgr3.static.verdnatura.es +swarm-worker1 ansible_host=swarm-worker1.static.verdnatura.es +swarm-worker2 ansible_host=swarm-worker2.static.verdnatura.es +swarm-worker3 ansible_host=swarm-worker3.static.verdnatura.es +swarm-worker4 ansible_host=swarm-worker4.static.verdnatura.es +swarm-proxy1 ansible_host=swarm-proxy1.static.verdnatura.es +swarm-proxy2 ansible_host=swarm-proxy2.static.verdnatura.es + +[vmware] + +ve3 ansible_host=ve3.verdnatura.es +ve4 ansible_host=ve4.verdnatura.es +ve5 ansible_host=ve5.verdnatura.es +vcenter ansible_host=vcenter.verdnatura.es + + +[pro-linux] db ansible_host=db.static.verdnatura.es pbx ansible_host=pbx.static.verdnatura.es +db1 ansible_host=db1.static.verdnatura.es +db2 ansible_host=db2.static.verdnatura.es +db3 ansible_host=db3.static.verdnatura.es windows ansible_host=windows.static.verdnatura.es test-win ansible_host=test-win.static.verdnatura.es nas ansible_host=nas.static.verdnatura.es test-db ansible_host=test-db.static.verdnatura.es +test-db1 ansible_host=test-db1.static.verdnatura.es +test-db2 ansible_host=test-db2.static.verdnatura.es +test-db3 ansible_host=test-db3.static.verdnatura.es +test-db-proxy1 ansible_host=test-db-proxy1.static.verdnatura.es +test-db-proxy2 ansible_host=test-db-proxy2.static.verdnatura.es +ldap-proxy1 ansible_host=ldap-proxy1.static.verdnatura.es +ldap-proxy2 ansible_host=ldap-proxy2.static.verdnatura.es server ansible_host=server.static.verdnatura.es +db-proxy1 ansible_host=db-proxy1.static.verdnatura.es +db-proxy2 ansible_host=db-proxy2.static.verdnatura.es +dev-db ansible_host=dev-db.static.verdnatura.es labels ansible_host=labels.static.verdnatura.es managedesktop ansible_host=managedesktop.static.verdnatura.es nas2 ansible_host=nas2.static.verdnatura.es @@ -36,32 +85,19 @@ mail ansible_host=mail.static.verdnatura.es sage ansible_host=sage.static.verdnatura.es vpn ansible_host=vpn.static.verdnatura.es a3 ansible_host=a3.static.verdnatura.es -swarm-proxy1 ansible_host=swarm-proxy1.static.verdnatura.es -swarm-proxy2 ansible_host=swarm-proxy2.static.verdnatura.es -test-db1 ansible_host=test-db1.static.verdnatura.es -test-db2 ansible_host=test-db2.static.verdnatura.es -test-db3 ansible_host=test-db3.static.verdnatura.es monthly-db ansible_host=monthly-db.static.verdnatura.es pmm ansible_host=pmm.static.verdnatura.es rds-licenses ansible_host=rds-licenses.static.verdnatura.es wac ansible_host=wac.static.verdnatura.es docuware ansible_host=docuware.static.verdnatura.es -swarm-mgr1 ansible_host=swarm-mgr1.static.verdnatura.es -swarm-mgr2 ansible_host=swarm-mgr2.static.verdnatura.es -swarm-mgr3 ansible_host=swarm-mgr3.static.verdnatura.es -swarm-worker1 ansible_host=swarm-worker1.static.verdnatura.es -swarm-worker2 ansible_host=swarm-worker2.static.verdnatura.es -swarm-worker3 ansible_host=swarm-worker3.static.verdnatura.es integra2 ansible_host=integra2.static.verdnatura.es -test-db-proxy1 ansible_host=test-db-proxy1.static.verdnatura.es -test-db-proxy2 ansible_host=test-db-proxy2.static.verdnatura.es -swarm-worker4 ansible_host=swarm-worker4.static.verdnatura.es -ldap-proxy1 ansible_host=ldap-proxy1.static.verdnatura.es -ldap-proxy2 ansible_host=ldap-proxy2.static.verdnatura.es goat ansible_host=goat.static.verdnatura.es -kube-master1 ansible_host=kube-master1.static.verdnatura.es -kube-master2 ansible_host=kube-master2.static.verdnatura.es -kube-master3 ansible_host=kube-master3.static.verdnatura.es +test801 ansible_host=test801.static.verdnatura.es + +[pro-windows] +adwindows ansible_host=adwindows.static.verdnatura.es +franceexpress ansible_host=franceexpress.static.verdnatura.es +logiflora ansible_host=logiflora.static.verdnatura.es bt1 ansible_host=bt1.static.verdnatura.es bt2 ansible_host=bt2.static.verdnatura.es rdswebbbdd ansible_host=rdswebbbdd.static.verdnatura.es @@ -71,20 +107,4 @@ mrw ansible_host=mrw.static.verdnatura.es focal ansible_host=focal.static.verdnatura.es reports ansible_host=reports.static.verdnatura.es printserver ansible_host=printserver.static.verdnatura.es -db1 ansible_host=db1.static.verdnatura.es -db2 ansible_host=db2.static.verdnatura.es -db3 ansible_host=db3.static.verdnatura.es -db-proxy1 ansible_host=db-proxy1.static.verdnatura.es -db-proxy2 ansible_host=db-proxy2.static.verdnatura.es -dev-db ansible_host=dev-db.static.verdnatura.es -test801 ansible_host=test801.static.verdnatura.es -adwindows ansible_host=adwindows.static.verdnatura.es -franceexpress ansible_host=franceexpress.static.verdnatura.es -logiflora ansible_host=logiflora.static.verdnatura.es -kube-worker1 ansible_host=kube-worker1.static.verdnatura.es -kube-worker2 ansible_host=kube-worker2.static.verdnatura.es -kube-worker3 ansible_host=kube-worker3.static.verdnatura.es -kube-worker4 ansible_host=kube-worker4.static.verdnatura.es -kube-proxy1 ansible_host=kube-proxy1.static.verdnatura.es -kube-proxy2 ansible_host=kube-proxy2.static.verdnatura.es -kube-helm ansible_host=kube-helm.static.verdnatura.es + From 38d148339de7341b045f6f9d70ec9b63851a668c Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 19:44:34 +0000 Subject: [PATCH 12/49] Update os/os-release.yml --- os/os-release.yml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/os/os-release.yml b/os/os-release.yml index 656a93a..7f00058 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -1,9 +1,15 @@ --- -- hosts: "{{ host }}" - gather_facts: True - tasks: - - name: Check Dist Version - shell: cat /etc/os-release - register: response +- name: Obtener la versión del sistema operativo + hosts: "{{ host }}" + gather_facts: yes - - debug: msg="{{ response.stdout }}" \ No newline at end of file + tasks: + - name: Mostrar la versión de Debian + when: ansible_distribution == 'Debian' + debug: + msg: "La versión de Ubuntu en {{ inventory_hostname }} es {{ ansible_distribution_version }}" + + - name: Mostrar la versión de CentOS + when: ansible_distribution == 'CentOS' + debug: + msg: "La versión de CentOS en {{ inventory_hostname }} es {{ ansible_distribution_version }}" From 9a39cd5d78379ce61a18604dce2302b2332c498e Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 19:50:15 +0000 Subject: [PATCH 13/49] Update os/os-release.yml --- os/os-release.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/os/os-release.yml b/os/os-release.yml index 7f00058..6ea51a5 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -7,9 +7,5 @@ - name: Mostrar la versión de Debian when: ansible_distribution == 'Debian' debug: - msg: "La versión de Ubuntu en {{ inventory_hostname }} es {{ ansible_distribution_version }}" + msg: "La versión de Ubuntu en {{ inventory_hostname }} es {{ ansible_distribution_release }} V. {{ ansible_distribution_version }}" - - name: Mostrar la versión de CentOS - when: ansible_distribution == 'CentOS' - debug: - msg: "La versión de CentOS en {{ inventory_hostname }} es {{ ansible_distribution_version }}" From b6402bfacf8376d4d1d346fbcb59fdd8762f2a14 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 19:53:33 +0000 Subject: [PATCH 14/49] Update os/os-release.yml --- os/os-release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/os/os-release.yml b/os/os-release.yml index 6ea51a5..11c26cb 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -7,5 +7,4 @@ - name: Mostrar la versión de Debian when: ansible_distribution == 'Debian' debug: - msg: "La versión de Ubuntu en {{ inventory_hostname }} es {{ ansible_distribution_release }} V. {{ ansible_distribution_version }}" - + msg: "El sistema operativo en {{ inventory_hostname }} es {{ ansible_facts['ansible_distribution'] }} {{ ansible_facts['ansible_distribution_version'] }}" From 0bc48223f3025ea8781364d234ff1b27743eb864 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 19:56:39 +0000 Subject: [PATCH 15/49] Update os/os-release.yml --- os/os-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/os-release.yml b/os/os-release.yml index 11c26cb..2f5e9f9 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -7,4 +7,4 @@ - name: Mostrar la versión de Debian when: ansible_distribution == 'Debian' debug: - msg: "El sistema operativo en {{ inventory_hostname }} es {{ ansible_facts['ansible_distribution'] }} {{ ansible_facts['ansible_distribution_version'] }}" + msg: "El sistema operativo en {{ inventory_hostname }} es {{ ansible_distribution }} {{ ansible_distribution_version ] }}" From 2615679635e59b5c01e6d5763a3d2526c23749ae Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 19:57:54 +0000 Subject: [PATCH 16/49] Update os/os-release.yml --- os/os-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/os-release.yml b/os/os-release.yml index 2f5e9f9..33f2463 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -7,4 +7,4 @@ - name: Mostrar la versión de Debian when: ansible_distribution == 'Debian' debug: - msg: "El sistema operativo en {{ inventory_hostname }} es {{ ansible_distribution }} {{ ansible_distribution_version ] }}" + msg: "El sistema operativo en {{ inventory_hostname }} es {{ ansible_distribution }} {{ ansible_distribution_version }}" From 5c8d48a65db5924c54c8270b96068b331cc3b94f Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 20:01:26 +0000 Subject: [PATCH 17/49] Update os/os-release.yml --- os/os-release.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/os/os-release.yml b/os/os-release.yml index 33f2463..b77d5d8 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -5,6 +5,7 @@ tasks: - name: Mostrar la versión de Debian - when: ansible_distribution == 'Debian' debug: - msg: "El sistema operativo en {{ inventory_hostname }} es {{ ansible_distribution }} {{ ansible_distribution_version }}" + #msg: "El sistema operativo en {{ inventory_hostname }} es {{ ansible_distribution }} {{ ansible_distribution_version }}" + msg: "El pretty name de {{ ansible_facts['ansible_distribution'] }} {{ ansible_facts['ansible_distribution_version'] }} es {{ ansible_facts['ansible_lsb']['description'] }}" + From 7a55f2757aeca4f6a3b9aa288618008264c61580 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 20:03:47 +0000 Subject: [PATCH 18/49] Update os/os-release.yml --- os/os-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/os-release.yml b/os/os-release.yml index b77d5d8..aa1f51d 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -7,5 +7,5 @@ - name: Mostrar la versión de Debian debug: #msg: "El sistema operativo en {{ inventory_hostname }} es {{ ansible_distribution }} {{ ansible_distribution_version }}" - msg: "El pretty name de {{ ansible_facts['ansible_distribution'] }} {{ ansible_facts['ansible_distribution_version'] }} es {{ ansible_facts['ansible_lsb']['description'] }}" + msg: "El pretty name de {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_lsb }}" From a8bc9bf9045670ce2454c1a5201fdc31fdd9a9c9 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 20:06:52 +0000 Subject: [PATCH 19/49] Update os/os-release.yml --- os/os-release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/os/os-release.yml b/os/os-release.yml index aa1f51d..953a5ef 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -8,4 +8,5 @@ debug: #msg: "El sistema operativo en {{ inventory_hostname }} es {{ ansible_distribution }} {{ ansible_distribution_version }}" msg: "El pretty name de {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_lsb }}" + msg: "El pretty name de {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_distribution }} {{ ansible_distribution_major_version }}" From db73c8e6f3108952178c4834dd49d73188f46d30 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 20:08:49 +0000 Subject: [PATCH 20/49] Update os/os-release.yml --- os/os-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/os/os-release.yml b/os/os-release.yml index 953a5ef..9e1190e 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -7,6 +7,6 @@ - name: Mostrar la versión de Debian debug: #msg: "El sistema operativo en {{ inventory_hostname }} es {{ ansible_distribution }} {{ ansible_distribution_version }}" - msg: "El pretty name de {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_lsb }}" - msg: "El pretty name de {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_distribution }} {{ ansible_distribution_major_version }}" + # msg: "El pretty name de {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_lsb }}" + msg: "OS is {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_distribution }} {{ ansible_distribution_major_version }}" From df5a614ce23279ea0ac47d9b30f3a37c2ee7d936 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 20:19:11 +0000 Subject: [PATCH 21/49] Update os/os-release.yml --- os/os-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/os-release.yml b/os/os-release.yml index 9e1190e..7747f89 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -8,5 +8,5 @@ debug: #msg: "El sistema operativo en {{ inventory_hostname }} es {{ ansible_distribution }} {{ ansible_distribution_version }}" # msg: "El pretty name de {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_lsb }}" - msg: "OS is {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_distribution }} {{ ansible_distribution_major_version }}" + msg: "OS is {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_distribution }} in {{ ansible_facts['ansible_lsb']['codename'] }}" From cab78148b6d27f2cd46a73c0b9f1b8add5390647 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 20:20:50 +0000 Subject: [PATCH 22/49] Update os/os-release.yml --- os/os-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/os-release.yml b/os/os-release.yml index 7747f89..181364f 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -8,5 +8,5 @@ debug: #msg: "El sistema operativo en {{ inventory_hostname }} es {{ ansible_distribution }} {{ ansible_distribution_version }}" # msg: "El pretty name de {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_lsb }}" - msg: "OS is {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_distribution }} in {{ ansible_facts['ansible_lsb']['codename'] }}" + msg: "OS is {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_distribution }} in {{ ansible_lsb ['codename'] }}" From 86e625eaced8a2e097c4f472877de9f16aa4c9b8 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 26 Jul 2023 20:22:40 +0000 Subject: [PATCH 23/49] Update os/os-release.yml --- os/os-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os/os-release.yml b/os/os-release.yml index 181364f..4cc39a8 100644 --- a/os/os-release.yml +++ b/os/os-release.yml @@ -8,5 +8,5 @@ debug: #msg: "El sistema operativo en {{ inventory_hostname }} es {{ ansible_distribution }} {{ ansible_distribution_version }}" # msg: "El pretty name de {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_lsb }}" - msg: "OS is {{ ansible_distribution }} {{ ansible_distribution_version }} es {{ ansible_distribution }} in {{ ansible_lsb ['codename'] }}" + msg: "OS is {{ ansible_distribution }} version {{ ansible_distribution_version }} codename {{ ansible_lsb ['codename'] }}" From 26aaf2c9a2b8535a4fb9acea1fc723dbd0b988a6 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 07:20:16 +0000 Subject: [PATCH 24/49] Add create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 create_user_ssh/check_authorizzed_key.yml diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml new file mode 100644 index 0000000..e69de29 From 2eae709acd76c57bed84a7e466f60460175957da Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 07:23:49 +0000 Subject: [PATCH 25/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index e69de29..0b99059 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -0,0 +1,19 @@ +--- +- name: Check Authorized Key Existence + hosts: "{{ hosts}} + gather_facts: yes + + tasks: + - name: Read authorized_keys file + shell: cat ~/.ssh/authorized_keys + register: authorized_keys_output + ignore_errors: yes + + - name: Check if authorized key exists + set_fact: + authorized_key_exists: "{{ lookup('search', 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDHFG9s2iWDwiBTHmczwtXnH276FfAY5ehCmMkB6KMIrKl38DHxEWY3ajHUdnXsN7kL9EGmh4cKMaW3MYtDTFVAFs3dzupyJuOMbSV3KWXn5dcOfmV4m6IxjV8fyVQSF7xEmD/vXFxJOzY7wJnYMnAGD1RCqVx7r6XefCqHoXLm2LQ/IcIjFiBa3QeSW8KZ5wdHdoGtFYJFrPipr7RZ/ByU144AWyaxEloEdYwzOmzY2BOLsmst+Q8GBa8CCDiTnehLp/4Jxpvz5pByaIpqCh1od4Wpi+01id0FlKOPPvzu6GvkkQ5Vp3Eq2KvnDQENN6/rgnbvozs0JpjsLNKfb2x5Bkgjts3GYhdNWxEPpxCThtCzsRGUYb+XcRzG2ufmdYdq+nT+tPxOpI9MX2MnR+M/Z2u2aL8zWfEei73xg09UO5xgHPhW/hzyVHlLljO6qgAfZui/12FEUzbIBESNsoIc6mspvQcQhUdreaeFa8qlxqZ9rr5CmX+lRrnszbcHo9s0BmNUnt8BS79krHfJ0s/k8aCN0t+JPJF2yJNgxDGW9URS8kMfgHFbETsj0kZ87EueU6Opom9cy9QKxGa/hmm+WzO50EaQR6MEk2doc6J9tcVOnF0qAifCc+++89XBS7BmEiTa+WoV2/Znw/4ScmsxVjo6MKHB8cNR6q6CMMyLJw== rvalles@ubuntu1604', content) | bool }}" + when: authorized_keys_output.rc == 0 + + - name: Display result + debug: + msg: "Authorized key exists: {{ authorized_key_exists | default(false) }}" From 08e32d84043a02c152aac2903b9f704ab57ac0a8 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 08:11:58 +0000 Subject: [PATCH 26/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index 0b99059..c6f0b6d 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -1,6 +1,6 @@ --- - name: Check Authorized Key Existence - hosts: "{{ hosts}} + hosts: "{{ hosts}}" gather_facts: yes tasks: From 523bf213ae21fd510e74f41e4bc6a2f14e8cb31b Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 08:15:11 +0000 Subject: [PATCH 27/49] Update hosts --- hosts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts b/hosts index 83249ab..d37a617 100644 --- a/hosts +++ b/hosts @@ -9,7 +9,7 @@ mox5 ansible_host=mox5.verdnatura.es mox91 ansible_host=mox91.verdnatura.es mox92 ansible_host=mox92.verdnatura.es mox93 ansible_host=mox93.verdnatura.es -docker ansible_host=10.0.6.116 +docker ansible_host=.6.171 [ilo] From 17a748b4c6ade1acdc33ad3499971268a3690533 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 08:16:49 +0000 Subject: [PATCH 28/49] Update hosts --- hosts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts b/hosts index d37a617..bd6efba 100644 --- a/hosts +++ b/hosts @@ -9,7 +9,7 @@ mox5 ansible_host=mox5.verdnatura.es mox91 ansible_host=mox91.verdnatura.es mox92 ansible_host=mox92.verdnatura.es mox93 ansible_host=mox93.verdnatura.es -docker ansible_host=.6.171 +docker ansible_host=10.0.6.171 [ilo] From 2c2da7256a621fdb3ec275b1e6e4fd70fafc357b Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 08:27:35 +0000 Subject: [PATCH 29/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index c6f0b6d..374f591 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -1,19 +1,19 @@ --- - name: Check Authorized Key Existence - hosts: "{{ hosts}}" + hosts: "{{ hosts }}" gather_facts: yes tasks: - name: Read authorized_keys file - shell: cat ~/.ssh/authorized_keys - register: authorized_keys_output + shell: cat ~/.ssh/authorized_keys | grep "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDHFG9s2iWDwiBTHmczwtXnH276FfAY5ehCmMkB6KMIrKl38DHxEWY3ajHUdnXsN7kL9EGmh4cKMaW3MYtDTFVAFs3dzupyJuOMbSV3KWXn5dcOfmV4m6IxjV8fyVQSF7xEmD/vXFxJOzY7wJnYMnAGD1RCqVx7r6XefCqHoXLm2LQ/IcIjFiBa3QeSW8KZ5wdHdoGtFYJFrPipr7RZ/ByU144AWyaxEloEdYwzOmzY2BOLsmst+Q8GBa8CCDiTnehLp/4Jxpvz5pByaIpqCh1od4Wpi+01id0FlKOPPvzu6GvkkQ5Vp3Eq2KvnDQENN6/rgnbvozs0JpjsLNKfb2x5Bkgjts3GYhdNWxEPpxCThtCzsRGUYb+XcRzG2ufmdYdq+nT+tPxOpI9MX2MnR+M/Z2u2aL8zWfEei73xg09UO5xgHPhW/hzyVHlLljO6qgAfZui/12FEUzbIBESNsoIc6mspvQcQhUdreaeFa8qlxqZ9rr5CmX+lRrnszbcHo9s0BmNUnt8BS79krHfJ0s/k8aCN0t+JPJF2yJNgxDGW9URS8kMfgHFbETsj0kZ87EueU6Opom9cy9QKxGa/hmm+WzO50EaQR6MEk2doc6J9tcVOnF0qAifCc+++89XBS7BmEiTa+WoV2/Znw/4ScmsxVjo6MKHB8cNR6q6CMMyLJw== rvalles@ubuntu1604'" + register: authorized_key_output ignore_errors: yes - name: Check if authorized key exists set_fact: - authorized_key_exists: "{{ lookup('search', 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDHFG9s2iWDwiBTHmczwtXnH276FfAY5ehCmMkB6KMIrKl38DHxEWY3ajHUdnXsN7kL9EGmh4cKMaW3MYtDTFVAFs3dzupyJuOMbSV3KWXn5dcOfmV4m6IxjV8fyVQSF7xEmD/vXFxJOzY7wJnYMnAGD1RCqVx7r6XefCqHoXLm2LQ/IcIjFiBa3QeSW8KZ5wdHdoGtFYJFrPipr7RZ/ByU144AWyaxEloEdYwzOmzY2BOLsmst+Q8GBa8CCDiTnehLp/4Jxpvz5pByaIpqCh1od4Wpi+01id0FlKOPPvzu6GvkkQ5Vp3Eq2KvnDQENN6/rgnbvozs0JpjsLNKfb2x5Bkgjts3GYhdNWxEPpxCThtCzsRGUYb+XcRzG2ufmdYdq+nT+tPxOpI9MX2MnR+M/Z2u2aL8zWfEei73xg09UO5xgHPhW/hzyVHlLljO6qgAfZui/12FEUzbIBESNsoIc6mspvQcQhUdreaeFa8qlxqZ9rr5CmX+lRrnszbcHo9s0BmNUnt8BS79krHfJ0s/k8aCN0t+JPJF2yJNgxDGW9URS8kMfgHFbETsj0kZ87EueU6Opom9cy9QKxGa/hmm+WzO50EaQR6MEk2doc6J9tcVOnF0qAifCc+++89XBS7BmEiTa+WoV2/Znw/4ScmsxVjo6MKHB8cNR6q6CMMyLJw== rvalles@ubuntu1604', content) | bool }}" - when: authorized_keys_output.rc == 0 + authorized_key_exists: "{{ authorized_key_output.stdout | length > 0 }}" + when: authorized_key_output.rc == 0 - name: Display result debug: - msg: "Authorized key exists: {{ authorized_key_exists | default(false) }}" + msg: "Authorized key exists: {{ authorized_key_exists | default(false) }}" \ No newline at end of file From 758191c3557d077c52dc674b5563b425698f6a63 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 08:31:28 +0000 Subject: [PATCH 30/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index 374f591..27d012e 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -5,7 +5,7 @@ tasks: - name: Read authorized_keys file - shell: cat ~/.ssh/authorized_keys | grep "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDHFG9s2iWDwiBTHmczwtXnH276FfAY5ehCmMkB6KMIrKl38DHxEWY3ajHUdnXsN7kL9EGmh4cKMaW3MYtDTFVAFs3dzupyJuOMbSV3KWXn5dcOfmV4m6IxjV8fyVQSF7xEmD/vXFxJOzY7wJnYMnAGD1RCqVx7r6XefCqHoXLm2LQ/IcIjFiBa3QeSW8KZ5wdHdoGtFYJFrPipr7RZ/ByU144AWyaxEloEdYwzOmzY2BOLsmst+Q8GBa8CCDiTnehLp/4Jxpvz5pByaIpqCh1od4Wpi+01id0FlKOPPvzu6GvkkQ5Vp3Eq2KvnDQENN6/rgnbvozs0JpjsLNKfb2x5Bkgjts3GYhdNWxEPpxCThtCzsRGUYb+XcRzG2ufmdYdq+nT+tPxOpI9MX2MnR+M/Z2u2aL8zWfEei73xg09UO5xgHPhW/hzyVHlLljO6qgAfZui/12FEUzbIBESNsoIc6mspvQcQhUdreaeFa8qlxqZ9rr5CmX+lRrnszbcHo9s0BmNUnt8BS79krHfJ0s/k8aCN0t+JPJF2yJNgxDGW9URS8kMfgHFbETsj0kZ87EueU6Opom9cy9QKxGa/hmm+WzO50EaQR6MEk2doc6J9tcVOnF0qAifCc+++89XBS7BmEiTa+WoV2/Znw/4ScmsxVjo6MKHB8cNR6q6CMMyLJw== rvalles@ubuntu1604'" + shell: cat ~/.ssh/authorized_keys | grep "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDHFG9s2iWDwiBTHmczwtXnH276FfAY5ehCmMkB6KMIrKl38DHxEWY3ajHUdnXsN7kL9EGmh4cKMaW3MYtDTFVAFs3dzupyJuOMbSV3KWXn5dcOfmV4m6IxjV8fyVQSF7xEmD/vXFxJOzY7wJnYMnAGD1RCqVx7r6XefCqHoXLm2LQ/IcIjFiBa3QeSW8KZ5wdHdoGtFYJFrPipr7RZ/ByU144AWyaxEloEdYwzOmzY2BOLsmst+Q8GBa8CCDiTnehLp/4Jxpvz5pByaIpqCh1od4Wpi+01id0FlKOPPvzu6GvkkQ5Vp3Eq2KvnDQENN6/rgnbvozs0JpjsLNKfb2x5Bkgjts3GYhdNWxEPpxCThtCzsRGUYb+XcRzG2ufmdYdq+nT+tPxOpI9MX2MnR+M/Z2u2aL8zWfEei73xg09UO5xgHPhW/hzyVHlLljO6qgAfZui/12FEUzbIBESNsoIc6mspvQcQhUdreaeFa8qlxqZ9rr5CmX+lRrnszbcHo9s0BmNUnt8BS79krHfJ0s/k8aCN0t+JPJF2yJNgxDGW9URS8kMfgHFbETsj0kZ87EueU6Opom9cy9QKxGa/hmm+WzO50EaQR6MEk2doc6J9tcVOnF0qAifCc+++89XBS7BmEiTa+WoV2/Znw/4ScmsxVjo6MKHB8cNR6q6CMMyLJw== rvalles@ubuntu1604" register: authorized_key_output ignore_errors: yes From 06d8238a55dc8403a34eae188532be12323f1f7a Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 08:37:01 +0000 Subject: [PATCH 31/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index 27d012e..5c23dc7 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -1,11 +1,14 @@ --- -- name: Check Authorized Key Existence +- name: Check and Add Authorized Key hosts: "{{ hosts }}" gather_facts: yes + vars: + public_key_to_add: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDHFG9s2iWDwiBTHmczwtXnH276FfAY5ehCmMkB6KMIrKl38DHxEWY3ajHUdnXsN7kL9EGmh4cKMaW3MYtDTFVAFs3dzupyJuOMbSV3KWXn5dcOfmV4m6IxjV8fyVQSF7xEmD/vXFxJOzY7wJnYMnAGD1RCqVx7r6XefCqHoXLm2LQ/IcIjFiBa3QeSW8KZ5wdHdoGtFYJFrPipr7RZ/ByU144AWyaxEloEdYwzOmzY2BOLsmst+Q8GBa8CCDiTnehLp/4Jxpvz5pByaIpqCh1od4Wpi+01id0FlKOPPvzu6GvkkQ5Vp3Eq2KvnDQENN6/rgnbvozs0JpjsLNKfb2x5Bkgjts3GYhdNWxEPpxCThtCzsRGUYb+XcRzG2ufmdYdq+nT+tPxOpI9MX2MnR+M/Z2u2aL8zWfEei73xg09UO5xgHPhW/hzyVHlLljO6qgAfZui/12FEUzbIBESNsoIc6mspvQcQhUdreaeFa8qlxqZ9rr5CmX+lRrnszbcHo9s0BmNUnt8BS79krHfJ0s/k8aCN0t+JPJF2yJNgxDGW9URS8kMfgHFbETsj0kZ87EueU6Opom9cy9QKxGa/hmm+WzO50EaQR6MEk2doc6J9tcVOnF0qAifCc+++89XBS7BmEiTa+WoV2/Znw/4ScmsxVjo6MKHB8cNR6q6CMMyLJw== rvalles@ubuntu1604" # Replace with the public key you want to add + tasks: - name: Read authorized_keys file - shell: cat ~/.ssh/authorized_keys | grep "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDHFG9s2iWDwiBTHmczwtXnH276FfAY5ehCmMkB6KMIrKl38DHxEWY3ajHUdnXsN7kL9EGmh4cKMaW3MYtDTFVAFs3dzupyJuOMbSV3KWXn5dcOfmV4m6IxjV8fyVQSF7xEmD/vXFxJOzY7wJnYMnAGD1RCqVx7r6XefCqHoXLm2LQ/IcIjFiBa3QeSW8KZ5wdHdoGtFYJFrPipr7RZ/ByU144AWyaxEloEdYwzOmzY2BOLsmst+Q8GBa8CCDiTnehLp/4Jxpvz5pByaIpqCh1od4Wpi+01id0FlKOPPvzu6GvkkQ5Vp3Eq2KvnDQENN6/rgnbvozs0JpjsLNKfb2x5Bkgjts3GYhdNWxEPpxCThtCzsRGUYb+XcRzG2ufmdYdq+nT+tPxOpI9MX2MnR+M/Z2u2aL8zWfEei73xg09UO5xgHPhW/hzyVHlLljO6qgAfZui/12FEUzbIBESNsoIc6mspvQcQhUdreaeFa8qlxqZ9rr5CmX+lRrnszbcHo9s0BmNUnt8BS79krHfJ0s/k8aCN0t+JPJF2yJNgxDGW9URS8kMfgHFbETsj0kZ87EueU6Opom9cy9QKxGa/hmm+WzO50EaQR6MEk2doc6J9tcVOnF0qAifCc+++89XBS7BmEiTa+WoV2/Znw/4ScmsxVjo6MKHB8cNR6q6CMMyLJw== rvalles@ubuntu1604" + shell: cat ~/.ssh/authorized_keys | grep "{{ public_key_to_add }}" register: authorized_key_output ignore_errors: yes @@ -16,4 +19,11 @@ - name: Display result debug: - msg: "Authorized key exists: {{ authorized_key_exists | default(false) }}" \ No newline at end of file + msg: "Authorized key exists: {{ authorized_key_exists | default(false) }}" + + - name: Add authorized key + authorized_key: + user: root # Replace with the remote user's name + state: present + key: "{{ public_key_to_add }}" + when: not authorized_key_exists \ No newline at end of file From 1fd478f1269e930634f243373c9b08e4589fad9b Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 08:40:17 +0000 Subject: [PATCH 32/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index 5c23dc7..979649f 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -1,10 +1,10 @@ --- - name: Check and Add Authorized Key - hosts: "{{ hosts }}" + hosts: "{{ host }}" gather_facts: yes vars: - public_key_to_add: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDHFG9s2iWDwiBTHmczwtXnH276FfAY5ehCmMkB6KMIrKl38DHxEWY3ajHUdnXsN7kL9EGmh4cKMaW3MYtDTFVAFs3dzupyJuOMbSV3KWXn5dcOfmV4m6IxjV8fyVQSF7xEmD/vXFxJOzY7wJnYMnAGD1RCqVx7r6XefCqHoXLm2LQ/IcIjFiBa3QeSW8KZ5wdHdoGtFYJFrPipr7RZ/ByU144AWyaxEloEdYwzOmzY2BOLsmst+Q8GBa8CCDiTnehLp/4Jxpvz5pByaIpqCh1od4Wpi+01id0FlKOPPvzu6GvkkQ5Vp3Eq2KvnDQENN6/rgnbvozs0JpjsLNKfb2x5Bkgjts3GYhdNWxEPpxCThtCzsRGUYb+XcRzG2ufmdYdq+nT+tPxOpI9MX2MnR+M/Z2u2aL8zWfEei73xg09UO5xgHPhW/hzyVHlLljO6qgAfZui/12FEUzbIBESNsoIc6mspvQcQhUdreaeFa8qlxqZ9rr5CmX+lRrnszbcHo9s0BmNUnt8BS79krHfJ0s/k8aCN0t+JPJF2yJNgxDGW9URS8kMfgHFbETsj0kZ87EueU6Opom9cy9QKxGa/hmm+WzO50EaQR6MEk2doc6J9tcVOnF0qAifCc+++89XBS7BmEiTa+WoV2/Znw/4ScmsxVjo6MKHB8cNR6q6CMMyLJw== rvalles@ubuntu1604" # Replace with the public key you want to add + public_key_to_add: "{{ key to add }}" tasks: - name: Read authorized_keys file From c7a39ccb08bdf3bf6c240320b61716d532b2e3eb Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 08:43:07 +0000 Subject: [PATCH 33/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index 979649f..16b9d30 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -1,6 +1,6 @@ --- - name: Check and Add Authorized Key - hosts: "{{ host }}" + hosts: "{{ hosts }}" gather_facts: yes vars: From d2af5ec42f3939fa0302e0ca8760f85547b9c8f7 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 08:44:01 +0000 Subject: [PATCH 34/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index 16b9d30..979649f 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -1,6 +1,6 @@ --- - name: Check and Add Authorized Key - hosts: "{{ hosts }}" + hosts: "{{ host }}" gather_facts: yes vars: From c002006cd0f084adec081ba0f20672a4e83b18be Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 08:45:17 +0000 Subject: [PATCH 35/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index 979649f..8ae2755 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -4,7 +4,7 @@ gather_facts: yes vars: - public_key_to_add: "{{ key to add }}" + public_key_to_add: "{{ key_to_add }}" tasks: - name: Read authorized_keys file From 6d6dbf5d235d3b259ef373380f34fe3017503334 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 08:48:31 +0000 Subject: [PATCH 36/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index 8ae2755..c3410a7 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -25,5 +25,5 @@ authorized_key: user: root # Replace with the remote user's name state: present - key: "{{ public_key_to_add }}" + key: "{{ key_to_add }}" when: not authorized_key_exists \ No newline at end of file From 14cfb6976e28d788ac506da584c3d0ef7787da94 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 08:50:58 +0000 Subject: [PATCH 37/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index c3410a7..a9ebbb7 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -3,12 +3,9 @@ hosts: "{{ host }}" gather_facts: yes - vars: - public_key_to_add: "{{ key_to_add }}" - tasks: - name: Read authorized_keys file - shell: cat ~/.ssh/authorized_keys | grep "{{ public_key_to_add }}" + shell: cat ~/.ssh/authorized_keys | grep "{{ key_to_add }}" register: authorized_key_output ignore_errors: yes From bb992fa54a3582f7688ec19557fb31f145910d30 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 09:01:17 +0000 Subject: [PATCH 38/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index a9ebbb7..7742fdb 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -16,7 +16,7 @@ - name: Display result debug: - msg: "Authorized key exists: {{ authorized_key_exists | default(false) }}" + msg: "Authorized key exists: {{ authorized_key_exists }}" - name: Add authorized key authorized_key: From b72d005b960967e198019b4c7b76cc42cd3602b6 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 09:05:59 +0000 Subject: [PATCH 39/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index 7742fdb..f950608 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -16,11 +16,11 @@ - name: Display result debug: - msg: "Authorized key exists: {{ authorized_key_exists }}" + msg: "Authorized key exists: {{ authorized_key_exists | default(false) }}" - name: Add authorized key authorized_key: user: root # Replace with the remote user's name state: present key: "{{ key_to_add }}" - when: not authorized_key_exists \ No newline at end of file + when: authorized_key_exists | default(false) | not \ No newline at end of file From 8678290e6bb6d5a4c725f2f9c805057ca2f65d06 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 09:09:05 +0000 Subject: [PATCH 40/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index f950608..3bd019b 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -23,4 +23,10 @@ user: root # Replace with the remote user's name state: present key: "{{ key_to_add }}" - when: authorized_key_exists | default(false) | not \ No newline at end of file + + rescue: + - name: Handle error when key already exists + debug: + msg: "The authorized key already exists. Skipping addition." + + when: not authorized_key_exists | default(false) \ No newline at end of file From e7fe212fba59441e871f9abff57da28cfe81bda3 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 09:13:19 +0000 Subject: [PATCH 41/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index 3bd019b..00444d9 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -18,15 +18,16 @@ debug: msg: "Authorized key exists: {{ authorized_key_exists | default(false) }}" - - name: Add authorized key - authorized_key: - user: root # Replace with the remote user's name - state: present - key: "{{ key_to_add }}" - + - name: Add authorized key if it does not exist + block: + - name: Add authorized key + authorized_key: + user: root # Replace with the remote user's name + state: present + key: "{{ key_to_add }}" rescue: - name: Handle error when key already exists debug: msg: "The authorized key already exists. Skipping addition." - when: not authorized_key_exists | default(false) \ No newline at end of file + when: not authorized_key_exists | default(false) From ca113a58a4781e6d328d7270a6b5c779e450ea08 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 09:17:54 +0000 Subject: [PATCH 42/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 25 +++++++++-------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index 00444d9..1de9a06 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -3,31 +3,26 @@ hosts: "{{ host }}" gather_facts: yes + vars: + public_key_to_add: "{ key_to_add}" # Replace with the public key you want to add + tasks: - name: Read authorized_keys file - shell: cat ~/.ssh/authorized_keys | grep "{{ key_to_add }}" + shell: cat ~/.ssh/authorized_keys | grep "{{ public_key_to_add }}" register: authorized_key_output ignore_errors: yes - name: Check if authorized key exists set_fact: - authorized_key_exists: "{{ authorized_key_output.stdout | length > 0 }}" - when: authorized_key_output.rc == 0 + authorized_key_exists: "{{ authorized_key_output.stdout_lines | length > 0 }}" - name: Display result debug: msg: "Authorized key exists: {{ authorized_key_exists | default(false) }}" - - name: Add authorized key if it does not exist - block: - - name: Add authorized key - authorized_key: - user: root # Replace with the remote user's name - state: present - key: "{{ key_to_add }}" - rescue: - - name: Handle error when key already exists - debug: - msg: "The authorized key already exists. Skipping addition." - + - name: Add authorized key + authorized_key: + user: root # Replace with the remote user's name + state: present + key: "{{ public_key_to_add }}" when: not authorized_key_exists | default(false) From 2512bec4aa0216ed4fac72c5acab257faa541efb Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 09:21:37 +0000 Subject: [PATCH 43/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index 1de9a06..dc8cafb 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -3,12 +3,9 @@ hosts: "{{ host }}" gather_facts: yes - vars: - public_key_to_add: "{ key_to_add}" # Replace with the public key you want to add - tasks: - name: Read authorized_keys file - shell: cat ~/.ssh/authorized_keys | grep "{{ public_key_to_add }}" + shell: cat ~/.ssh/authorized_keys | grep "{{ key_to_add }}" register: authorized_key_output ignore_errors: yes @@ -24,5 +21,5 @@ authorized_key: user: root # Replace with the remote user's name state: present - key: "{{ public_key_to_add }}" + key: "{{ key_to_add }}" when: not authorized_key_exists | default(false) From 5b7f960f310914997636543dbc1a9fa59162ddc2 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 09:25:41 +0000 Subject: [PATCH 44/49] Update create_user_ssh/check_authorizzed_key.yml --- create_user_ssh/check_authorizzed_key.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorizzed_key.yml index dc8cafb..9a97954 100644 --- a/create_user_ssh/check_authorizzed_key.yml +++ b/create_user_ssh/check_authorizzed_key.yml @@ -15,7 +15,7 @@ - name: Display result debug: - msg: "Authorized key exists: {{ authorized_key_exists | default(false) }}" + msg: "Authorized key exists: {{ authorized_key_exists }}" - name: Add authorized key authorized_key: From 190fa01b63da726c90c26f2e81c549f5ad08d5c3 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 09:34:00 +0000 Subject: [PATCH 45/49] Update hosts --- hosts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hosts b/hosts index bd6efba..7e55bd0 100644 --- a/hosts +++ b/hosts @@ -1,4 +1,4 @@ -[servers] +# Group names should not contain any special characters except for underscores _, hyphens -, and periods .. [proxmox] mox1 ansible_host=mox1.verdnatura.es @@ -56,7 +56,7 @@ ve5 ansible_host=ve5.verdnatura.es vcenter ansible_host=vcenter.verdnatura.es -[pro-linux] +[pro_linux] db ansible_host=db.static.verdnatura.es pbx ansible_host=pbx.static.verdnatura.es @@ -94,7 +94,7 @@ integra2 ansible_host=integra2.static.verdnatura.es goat ansible_host=goat.static.verdnatura.es test801 ansible_host=test801.static.verdnatura.es -[pro-windows] +[pro_windows] adwindows ansible_host=adwindows.static.verdnatura.es franceexpress ansible_host=franceexpress.static.verdnatura.es logiflora ansible_host=logiflora.static.verdnatura.es From 4f9cd693159b64e6eef45bfea8a137c2a4305c32 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 11:02:22 +0000 Subject: [PATCH 46/49] Update create_user_ssh/check_authorized_key.yml --- .../{check_authorizzed_key.yml => check_authorized_key.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename create_user_ssh/{check_authorizzed_key.yml => check_authorized_key.yml} (100%) diff --git a/create_user_ssh/check_authorizzed_key.yml b/create_user_ssh/check_authorized_key.yml similarity index 100% rename from create_user_ssh/check_authorizzed_key.yml rename to create_user_ssh/check_authorized_key.yml From f8316dc795975214b5ace53177eb9b0f2d9ad8bd Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 11:04:07 +0000 Subject: [PATCH 47/49] Update create_user_ssh/check_and _add_authorized_key.yml --- ...check_authorized_key.yml => check_and _add_authorized_key.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename create_user_ssh/{check_authorized_key.yml => check_and _add_authorized_key.yml} (100%) diff --git a/create_user_ssh/check_authorized_key.yml b/create_user_ssh/check_and _add_authorized_key.yml similarity index 100% rename from create_user_ssh/check_authorized_key.yml rename to create_user_ssh/check_and _add_authorized_key.yml From b534ca46b76512578b41a224022cb8b845a421ba Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 11:06:00 +0000 Subject: [PATCH 48/49] Update create_user_ssh/check_and _add_authorized_key.yml --- create_user_ssh/check_and _add_authorized_key.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_user_ssh/check_and _add_authorized_key.yml b/create_user_ssh/check_and _add_authorized_key.yml index 9a97954..60b3461 100644 --- a/create_user_ssh/check_and _add_authorized_key.yml +++ b/create_user_ssh/check_and _add_authorized_key.yml @@ -1,6 +1,6 @@ --- - name: Check and Add Authorized Key - hosts: "{{ host }}" + hosts: "{{ hosts }}" gather_facts: yes tasks: From 223caf1c9e50c5d76f5de7cf191832d9aa709a4e Mon Sep 17 00:00:00 2001 From: David Lopez Date: Thu, 27 Jul 2023 11:25:18 +0000 Subject: [PATCH 49/49] Update create_user_ssh/check_and _add_authorized_key.yml --- create_user_ssh/check_and _add_authorized_key.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_user_ssh/check_and _add_authorized_key.yml b/create_user_ssh/check_and _add_authorized_key.yml index 60b3461..5c58cd2 100644 --- a/create_user_ssh/check_and _add_authorized_key.yml +++ b/create_user_ssh/check_and _add_authorized_key.yml @@ -1,6 +1,6 @@ --- - name: Check and Add Authorized Key - hosts: "{{ hosts }}" + hosts: "{{ hosts_servers }}" gather_facts: yes tasks: