Merge branch 'main' of https://gitea.verdnatura.es/verdnatura/vn-ansible
This commit is contained in:
commit
a95a0b33fd
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
- name: Check and Add Authorized Key
|
||||||
|
hosts: "{{ hosts_servers }}"
|
||||||
|
gather_facts: yes
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Read authorized_keys file
|
||||||
|
shell: cat ~/.ssh/authorized_keys | grep "{{ 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_lines | length > 0 }}"
|
||||||
|
|
||||||
|
- name: Display result
|
||||||
|
debug:
|
||||||
|
msg: "Authorized key exists: {{ authorized_key_exists }}"
|
||||||
|
|
||||||
|
- 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 | default(false)
|
68
hosts
68
hosts
|
@ -24,27 +24,6 @@ test-db-proxy2 ansible_host=test-db-proxy2.static.verdnatura.es
|
||||||
monthly-db ansible_host=monthly-db.static.verdnatura.es
|
monthly-db ansible_host=monthly-db.static.verdnatura.es
|
||||||
dev-db ansible_host=dev-db.static.verdnatura.es
|
dev-db ansible_host=dev-db.static.verdnatura.es
|
||||||
|
|
||||||
swarm-proxy1 ansible_host=swarm-proxy1.static.verdnatura.es
|
|
||||||
swarm-proxy2 ansible_host=swarm-proxy2.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
|
|
||||||
swarm-worker4 ansible_host=swarm-worker4.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
|
|
||||||
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
|
|
||||||
|
|
||||||
[devices]
|
[devices]
|
||||||
|
|
||||||
nas2 ansible_host=nas2.static.verdnatura.es
|
nas2 ansible_host=nas2.static.verdnatura.es
|
||||||
|
@ -81,10 +60,9 @@ mox2 ansible_host=mox2.verdnatura.es
|
||||||
mox3 ansible_host=mox3.verdnatura.es
|
mox3 ansible_host=mox3.verdnatura.es
|
||||||
mox4 ansible_host=mox4.verdnatura.es
|
mox4 ansible_host=mox4.verdnatura.es
|
||||||
mox5 ansible_host=mox5.verdnatura.es
|
mox5 ansible_host=mox5.verdnatura.es
|
||||||
ve3 ansible_host=ve3.verdnatura.es
|
|
||||||
ve4 ansible_host=ve4.verdnatura.es
|
[ilo]
|
||||||
ve5 ansible_host=ve5.verdnatura.es
|
|
||||||
vcenter ansible_host=vcenter.verdnatura.es
|
|
||||||
mox1-ilo ansible_host=mox1-ilo.verdnatura.es
|
mox1-ilo ansible_host=mox1-ilo.verdnatura.es
|
||||||
mox2-ilo ansible_host=mox2-ilo.verdnatura.es
|
mox2-ilo ansible_host=mox2-ilo.verdnatura.es
|
||||||
mox3-ilo ansible_host=mox3-ilo.verdnatura.es
|
mox3-ilo ansible_host=mox3-ilo.verdnatura.es
|
||||||
|
@ -93,10 +71,42 @@ mox5-ilo ansible_host=mox5-ilo.verdnatura.es
|
||||||
ve3-ilo ansible_host=ve3-ilo.verdnatura.es
|
ve3-ilo ansible_host=ve3-ilo.verdnatura.es
|
||||||
ve4-ilo ansible_host=ve4-ilo.verdnatura.es
|
ve4-ilo ansible_host=ve4-ilo.verdnatura.es
|
||||||
ve5-ilo ansible_host=ve5-ilo.verdnatura.es
|
ve5-ilo ansible_host=ve5-ilo.verdnatura.es
|
||||||
mox91 ansible_host=mox91.verdnatura.es
|
|
||||||
mox92 ansible_host=mox92.verdnatura.es
|
[kubernetes]
|
||||||
mox93 ansible_host=mox93.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
|
||||||
|
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
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
|
|
||||||
docker ansible_host=10.0.6.116
|
mox91 ansible_host=mox91.verdnatura.es
|
||||||
|
mox92 ansible_host=mox92.verdnatura.es
|
||||||
|
mox93 ansible_host=mox93.verdnatura.es
|
||||||
|
docker ansible_host=10.0.6.171
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
- name: Obtener la versión del sistema operativo
|
||||||
|
hosts: "{{ host }}"
|
||||||
|
gather_facts: yes
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- 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: "OS is {{ ansible_distribution }} version {{ ansible_distribution_version }} codename {{ ansible_lsb ['codename'] }}"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
- hosts: "{{ host }}"
|
- hosts: "{{ host }}"
|
||||||
gather_facts: false
|
gather_facts: true
|
||||||
tasks:
|
tasks:
|
||||||
- ping:
|
- ping:
|
Loading…
Reference in New Issue