ansible-infra/ansible_collections/nullified/infrastructure/extensions/molecule/default/converge.yml

80 lines
2.7 KiB
YAML

---
# playbook file that contains the call for your role
- name: Fail if molecule group is missing
hosts: localhost
tasks:
- name: Assert group existence
ansible.builtin.assert:
that: "'molecule' in groups"
fail_msg: |
molecule group was not found inside inventory groups: {{ groups }}
- name: Converge
hosts: molecule
gather_facts: true
vars_files:
- ../../../../../../inventory/group_vars/all/vars.yml
- ../../../../../../inventory/group_vars/all/vault.yml
- ../../../../../../inventory/group_vars/provisioner/vars.yml
- ./platform_vars.yml
handlers:
- name: reboot vm
become: true
changed_when: false
ansible.builtin.reboot:
reboot_timeout: 10
tasks:
- include_vars: ../../../../../../inventory/group_vars/all/vars.yml
- include_vars: ../../../../../../inventory/group_vars/all/vault.yml
- include_vars: ../../../../../../inventory/group_vars/provisioner/vars.yml
- include_vars: ./platform_vars.yml
- name: Platform hostvars
ansible.builtin.debug:
msg: "{{ hostvars[inventory_hostname] }}"
verbosity: 1
- name: Upgrade system since vagrant boxes are often outdated
become: true
notify:
- reboot vm
ansible.builtin.apt:
update_cache: true
force_apt_get: true
cache_valid_time: 3600
autoremove: true
install_recommends: false
upgrade: full
- meta: flush_handlers
- name: Enable guest console access
become: true
ansible.builtin.systemd_service:
name: serial-getty@ttyS0.service
enabled: true
state: restarted
- name: Testing provisioner variables loading
ansible.builtin.include_role:
name: nullified.infrastructure.provisioner
tasks_from: load_facts.yml
- name: Testing security role
ansible.builtin.include_role:
name: nullified.infrastructure.security
tasks_from: main.yml
- name: Testing common role
ansible.builtin.include_role:
name: nullified.infrastructure.common
tasks_from: main.yml
- name: Testing server role
ansible.builtin.include_role:
name: nullified.infrastructure.server
tasks_from: main.yml
- name: Testing development role
ansible.builtin.include_role:
name: nullified.infrastructure.development
tasks_from: main.yml
- name: Testing workstation role
ansible.builtin.include_role:
name: nullified.infrastructure.workstation
tasks_from: main.yml
- name: Testing gaming role
ansible.builtin.include_role:
name: nullified.infrastructure.gaming
tasks_from: main.yml