diff --git a/README.md b/README.md new file mode 100644 index 0000000..87fe507 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# Verdnatura Ansible playbooks + +Collection of Ansible playbooks used in the Verdnatura server farm. + +## Install Ansible + +Instal Ansible on Debian. +``` +apt install ansible +``` + +## Run playbook + +Before merging changes into protected branches, playbooks should be tested +locally to ensure they work properly. + +To runan Ansible playbook locally on a temporary host without registering it in +the inventory (on the fly) run the following command. +``` +ansible-playbook playbooks/test.yml -u root -i , +``` + +*Note the comma at the end of the hostname or IP.* + +## Basic playbooks + +* **facts.yml**: Collect and display facts from a host. +* **ping.yml**: Checking that a host is alive and reachable by Ansible. +* **test.yml**: Test an specific role. Don't forget to undo changes before pushing! +* **debian.yml**: Setup base Debian server + +## Documentation + +* https://docs.ansible.com/ansible/latest/reference_appendices/config.html +* https://docs.ansible.com/ansible/latest/collections/ansible/builtin/gather_facts_module.html +* https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_vars_facts.html diff --git a/ansible.cfg b/ansible.cfg index e5b1de3..c46bb72 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,6 +1,6 @@ [defaults] roles_path = ./roles -inventory = ./hosts +inventory = ./inventories/production gathering = smart interpreter_python = auto_silent remote_user = awx-user diff --git a/group_vars/all.yml b/inventories/group_vars/all.yml similarity index 100% rename from group_vars/all.yml rename to inventories/group_vars/all.yml diff --git a/inventories/laboratory b/inventories/laboratory new file mode 100644 index 0000000..08668e3 --- /dev/null +++ b/inventories/laboratory @@ -0,0 +1,42 @@ +[laboratory] +corelab-proxy1 ansible_host=corelab-proxy1.lab.verdnatura.es +docker-itlab ansible_host=docker-itlab.lab.verdnatura.es +zammad ansible_host=zammad.lab.verdnatura.es +matrix ansible_host=matrix.lab.verdnatura.es +ansible-test ansible_host=ansible-test.lab.verdnatura.es + +[network] +opnsense1-test ansible_host=opnsense1-test.lab.verdnatura.es +opnsense2-test ansible_host=opnsense2-test.lab.verdnatura.es + +[cephlab] +cephlab01 ansible_host=cephlab01.lab.verdnatura.es +cephlab02 ansible_host=cephlab02.lab.verdnatura.es +cephlab03 ansible_host=cephlab03.lab.verdnatura.es + +[cephtest] +cephtest01 ansible_host=cephtest01.lab.verdnatura.es +cephtest02 ansible_host=cephtest02.lab.verdnatura.es +cephtest03 ansible_host=cephtest03.lab.verdnatura.es + +[kubepre] +kubepre-helm ansible_host=kubepre-helm.lab.verdnatura.es +kubepre-proxy1 ansible_host=kubepre-proxy1.lab.verdnatura.es +kubepre-proxy2 ansible_host=kubepre-proxy2.lab.verdnatura.es +kubepre-master1 ansible_host=kubepre-master1.lab.verdnatura.es +kubepre-master2 ansible_host=kubepre-master2.lab.verdnatura.es +kubepre-master3 ansible_host=kubepre-master3.lab.verdnatura.es +kubepre-worker1 ansible_host=kubepre-worker1.lab.verdnatura.es +kubepre-worker2 ansible_host=kubepre-worker2.lab.verdnatura.es +kubepre-worker3 ansible_host=kubepre-worker3.lab.verdnatura.es +kubepre-worker4 ansible_host=kubepre-worker4.lab.verdnatura.es + +[kubetest] +kubetest-helm ansible_host=kubetest-helm.lab.verdnatura.es +kubetest-master01 ansible_host=kubetest-master01.lab.verdnatura.es +kubetest-master02 ansible_host=kubetest-master02.lab.verdnatura.es +kubetest-master03 ansible_host=kubetest-master03.lab.verdnatura.es +kubetest-worker01 ansible_host=kubetest-worker01.lab.verdnatura.es +kubetest-worker02 ansible_host=kubetest-worker02.lab.verdnatura.es +kubetest-worker03 ansible_host=kubetest-worker03.lab.verdnatura.es +kubetest-worker04 ansible_host=kubetest-worker04.lab.verdnatura.es diff --git a/hosts b/inventories/production similarity index 100% rename from hosts rename to inventories/production diff --git a/playbooks/facts.yml b/playbooks/facts.yml index aeb0d4f..04ad610 100644 --- a/playbooks/facts.yml +++ b/playbooks/facts.yml @@ -1,5 +1,3 @@ -# https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_vars_facts.html - - hosts: all gather_facts: yes tasks: @@ -8,4 +6,4 @@ var: ansible_facts - name: Print variable value debug: - msg: "Variable: {{ awx_pub_key }}" + msg: "Variable: {{ ansible_fqdn }}" diff --git a/playbooks/test.yml b/playbooks/test.yml index 8032bff..65fd033 100644 --- a/playbooks/test.yml +++ b/playbooks/test.yml @@ -2,4 +2,4 @@ tasks: - name: Test role import_role: - name: linux-base + name: debian-base