Antonio Pulido 2 лет назад
Сommit
7aae1d702b

+ 0 - 0
T2-Ej/Ej4-Playbooks-sencillos/README.md


+ 9 - 0
T2-Ej/Ej4-Playbooks-sencillos/ansible.cfg

@@ -0,0 +1,9 @@
+[defaults]
+inventory = systems
+remote_user = devops
+[privilege_escalation]
+become = true
+become_method = sudo
+become_user = root
+become_ask_pass = false
+ 

+ 9 - 0
T2-Ej/Ej4-Playbooks-sencillos/borra_fichero_hola.yaml

@@ -0,0 +1,9 @@
+- name: Borra fichero hola en los hosts
+  hosts:
+    - all
+    - localhost
+  tasks:
+    - name: borra hola.txt
+      file:
+        - path: /tmp/hola.txt
+        - state: absent

+ 7 - 0
T2-Ej/Ej4-Playbooks-sencillos/borra_user_pepe.yml

@@ -0,0 +1,7 @@
+- name: Borra al usuario pepe
+  hosts: all
+  tasks:
+    user:
+      nombre: pepe
+      state: absent
+      remove: true

+ 9 - 0
T2-Ej/Ej4-Playbooks-sencillos/crea_fichero_hola.yaml

@@ -0,0 +1,9 @@
+- name: Crea fichero hola en los hosts
+  hosts:
+    - all
+    - localhost
+  tasks:
+    - name: crea el contenido de hola.txt
+      copy:
+        - dest: /tmp/hola.txt
+        - content: 'Hola Mundo!'

+ 8 - 0
T2-Ej/Ej4-Playbooks-sencillos/crea_user_pepe.yml

@@ -0,0 +1,8 @@
+- name: Crea el usuario pepe en los hosts
+  hosts: all
+  tasks:
+    - name: crea al usuario pepe
+      user:
+        - name: pepe
+        - state: present
+

+ 1 - 0
T2-Ej/Ej4-Playbooks-sencillos/host_vars/localhost

@@ -0,0 +1 @@
+ansible_connection: smart

+ 9 - 0
T2-Ej/Ej4-Playbooks-sencillos/modifica_motd.yaml

@@ -0,0 +1,9 @@
+- name: Modifica MOTD en los hosts
+  hosts:
+    - all
+    - localhost
+  tasks:
+    - name: cambia el contenido de MOTD
+      copy:
+        - dest: /etc/motd
+        - content: 'Sistema gestionado por Ansible'

+ 7 - 0
T2-Ej/Ej4-Playbooks-sencillos/systems

@@ -0,0 +1,7 @@
+[produccion]
+servera.lab.example.com
+serverd.lab.example.com
+[desarrollo]
+serverb.lab.example.com
+[sistemas]
+serverc.lab.example.com