Explorar el Código

feat: reorder execution to use roles instead of separate files

Douglas A hace 3 años
padre
commit
35921c9d2e
Se han modificado 9 ficheros con 69 adiciones y 83 borrados
  1. 0 15
      centos_update.yml
  2. 0 26
      debian_update.yml
  3. 0 13
      docker-playbook.yml
  4. 3 13
      hosts
  5. 19 0
      main.yaml
  6. 0 16
      qemu-guest.yml
  7. 10 0
      roles/centos/tasks/main.yaml
  8. 12 0
      roles/debian/tasks/main.yaml
  9. 25 0
      roles/packages/tasks/main.yaml

+ 0 - 15
centos_update.yml

@@ -1,15 +0,0 @@
----
-- hosts: omega
-  become_user: root
-  user: ansible
-  become: yes
-  tasks:
-    - name: update the system
-      dnf:
-        name: "*"
-        state: latest
-    - name: start cockpit
-      service:
-        name: cockpit
-        state: started
-

+ 0 - 26
debian_update.yml

@@ -1,26 +0,0 @@
----
-- hosts: debian
-  user: ansible
-  become_user: root
-  become: yes
-  tasks:
-    - name: update the system
-      apt:
-        upgrade: dist
-        update_cache: yes
-
-    - name: Remove useless packages from the cache
-      apt:
-        autoclean: yes
-
-    - name: Remove dependencies that are no longer required
-      apt:
-        autoremove: yes
-   
-    - name: Add acl for user
-      apt:
-        name: "{{ item }}"
-        state: present
-      with_items:
-        - acl
-        - python3-pip

+ 0 - 13
docker-playbook.yml

@@ -1,13 +0,0 @@
----
-- hosts: docker 
-  tasks:
-    - name: start container for ghost-blog
-      docker_container:
-        name: ghost-blog
-        state: started
-        ports:
-          - "15601:2368"
-        volumes:
-          - "/opt/ghost/blog:/var/lib/ghost/content"
-        env: 
-          url: "https://blog.andreanidr.com"

+ 3 - 13
hosts

@@ -1,4 +1,4 @@
-[omega]
+[centos]
 192.168.180.3
 192.168.180.4
 192.168.180.6
@@ -13,21 +13,11 @@
 192.168.180.7
 192.168.180.8
 192.168.180.9
-192.168.190.2
 plex.delta.labs.andreanidr.com
+192.168.100.227
 
 [debian:vars]
 ansible_python_interpreter=/usr/bin/python3
 
-[omega:vars]
+[centos:vars]
 ansible_python_interpreter=/usr/bin/python3
-
-
-[vms]
-192.168.100.3
-192.168.100.4
-192.168.100.12
-192.168.100.13
-192.168.100.15
-192.168.180.7
-

+ 19 - 0
main.yaml

@@ -0,0 +1,19 @@
+---
+- user: ansible
+  become_user: root
+  become: yes
+  hosts: debian
+  roles: 
+    - { role: debian, tags: debian-update } 
+    - { role: packages, tags: debian-packages }
+
+- hosts: centos
+  gather_facts: yes
+  user: ansible
+  become_user: root
+  become: yes
+  roles: 
+    - { role: centos, tags: centos-update } 
+    - { role: packages, tags: centos-packages }
+
+

+ 0 - 16
qemu-guest.yml

@@ -1,16 +0,0 @@
----
-- hosts: vms 
-  become_user: root
-  become: yes
-
-  tasks:
-    - name: install qemu-guest agent 
-      apt:
-        update_cache: yes
-        name: qemu-guest-agent
-        state: latest
-
-    - name: start qemu task agent
-      systemd:
-        state: started
-        name: qemu-guest-agent.service

+ 10 - 0
roles/centos/tasks/main.yaml

@@ -0,0 +1,10 @@
+---
+- name: update the system
+  dnf:
+    name: "*"
+    state: latest
+- name: start cockpit
+  service:
+    name: cockpit
+    state: started
+

+ 12 - 0
roles/debian/tasks/main.yaml

@@ -0,0 +1,12 @@
+---
+- name: update the system
+  apt:
+    upgrade: dist
+    update_cache: yes
+
+- name: Remove useless packages from the cache
+  apt:
+    autoclean: yes
+- name: Remove dependencies that are no longer required
+  apt:
+    autoremove: yes

+ 25 - 0
roles/packages/tasks/main.yaml

@@ -0,0 +1,25 @@
+---
+- name: Install required packages
+  package: name={{ item }} state=latest
+  with_items:
+    - vim
+    - nano
+    - htop
+    - python3
+    - python3-pip
+    - acl
+    - bash-completion
+
+
+- name: install debian specific packages
+  package: name={{ item }} state=latest
+  when: ansible_distribution == 'Debian'
+  with_items:
+    - lsb-release
+    - build-essential
+
+- name: install centos specific packages
+  package: name={{ item }} state=latest
+  when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'Rocky'
+  with_items:
+    - epel-release