Refactor playbooks and roles

This commit is contained in:
Fabio Sinibaldi 2025-08-12 17:46:38 +02:00
parent baa35fa85f
commit 7130569e6f
24 changed files with 99 additions and 8 deletions

View File

@ -1,2 +0,0 @@
---
#- hosts:

View File

@ -0,0 +1,68 @@
---
# play 1 - local
# check config info from inventory
# play 2
# gather status
# play 3
# bootstrap
# play 4
# join
- name: Tests
hosts: swarm
connection: local
gather_facts: no
vars:
swarm_list: {}
tasks:
- debug: var=hostvars
- name: Gather Swarm info
set_fact:
swarm_list: "{{swarm_list + hostvars[hostname]['swarm_name']}}"
- debug: var=swarm_list
# # show all the hosts in the inventory
# - debug:
# msg: "{{ item }}"
# loop: "{{ groups['all'] }}"
# - name: printsomthieng
# debug:
# msg: "{{ item }}"
# with_items: "{{ play_hosts }}"
# #run_once: true
# debug:
# msg:
# # - "{{ item }}"
# - "{{hostvars[item]['swarm_master']}}"
# #loop: "{{ hosts.items() | list }}"
# - name: Create swarm_<SWARM>_<MASTER|WORKER>_<OPERATIONAL|BOOTSTRAP> groups
# add_host:
# hostname: "{{ item }}"
# groups: "swarm_{{item}}manager_operational"
# with_items: "{{ play_hosts }}"
# run_once: true
# - name: Display
# command: echo "swarm_{{item}}manager_operational"

View File

@ -0,0 +1,6 @@
---
# NB inherit docker
- name: Create volumes
## TODO
- name: launch Nextcloud aio docker image

View File

@ -1,5 +1,5 @@
---
- name: "Configure swarms"
- name: "Configure swarm"
hosts: swarm1
roles:
- common
@ -10,7 +10,7 @@
hostname: "{{ item }}"
groups: manager_group
with_items: "{{play_hosts}}"
when: hostvars[item]['swarm_master']
when: hostvars[item]['swarm_master'] is defined and hostvars[item]['swarm_master']
- name: "Prepare worker group"
add_host:

View File

@ -1,15 +1,33 @@
# Ansible Playbooks
## Playbooks
##### Bootstrap
Creates user ansible with necessary privileges. Needs become password
## Usage
The inventory defines labs, nodes and their group based on function.
Playbooks run Roles against node groups.
Roles define set of Tasks.
## Playbooks
**Site** playbook launches them all.
**Bootstrap** is to be run first on new installations.
### Site
This playbook recalls all the following playbooks in the stated order.
'ansible-playbook -i inventories bootstrap.yml -l nextrup_copy_test -u fabio -K --ask-vault-password'
##### Nodes
Basic checks connectivity for **all**
##### Swarms
##### NextCloud
Installs Nextcloud AIO using SSE Lab / dockerized / nextcloud-aio
## Inventories

View File

@ -3,3 +3,4 @@
- import_playbook: nodes.yml
#- import_playbook: controller.yml
- import_playbook: swarms.yml
#- import_playbook: nextcloud.yml