chore!: separated galaxy deps and own collections; modified ansible script generation to use two paths for collections
REQUIRES REGENERATING ansible.cfg!
This commit is contained in:
parent
4af69c31ce
commit
888590ed9f
188 changed files with 30 additions and 30 deletions
|
@ -0,0 +1,60 @@
|
|||
---
|
||||
# playbook file that contains the call for your role
|
||||
- name: Fail if molecule group is missing
|
||||
hosts: localhost
|
||||
tasks:
|
||||
- name: Print some info
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ groups }}"
|
||||
|
||||
- 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
|
||||
- ./platform_vars.yml
|
||||
tasks:
|
||||
- include_vars: ../../../../../../../inventory/group_vars/all/vars.yml
|
||||
- include_vars: ../../../../../../../inventory/group_vars/all/vault.yml
|
||||
- include_vars: ./platform_vars.yml
|
||||
- name: Platform hostvars
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ hostvars[inventory_hostname] }}"
|
||||
verbosity: 1
|
||||
- name: Enable guest console access
|
||||
become: true
|
||||
ansible.builtin.systemd_service:
|
||||
name: serial-getty@ttyS0.service
|
||||
enabled: true
|
||||
state: restarted
|
||||
- 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
|
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
# playbook file used for creating the instances and storing data in instance-config
|
||||
- name: Create
|
||||
hosts: localhost
|
||||
gather_facts: false
|
||||
connection: local
|
||||
tasks:
|
||||
- name: Create instances
|
||||
vagrant:
|
||||
instances: "{{ molecule_yml.platforms }}"
|
||||
default_box: "{{ molecule_yml.driver.default_box | default('debian/bookworm64') }}"
|
||||
provider_name: "{{ molecule_yml.driver.provider.name | default(omit, true) }}"
|
||||
provision: "{{ molecule_yml.driver.provision | default(omit) }}"
|
||||
cachier: "{{ molecule_yml.driver.cachier | default(omit) }}"
|
||||
parallel: "{{ molecule_yml.driver.parallel | default(omit) }}"
|
||||
state: up
|
||||
register: server
|
||||
- name: VMs info
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ server.results }}"
|
||||
- name: Create molecule instances configuration
|
||||
when: server is changed # noqa no-handler
|
||||
block:
|
||||
- name: Populate instance config dict
|
||||
ansible.builtin.set_fact:
|
||||
instance_conf_dict:
|
||||
{
|
||||
"instance": "{{ item.Host }}",
|
||||
"address": "{{ item.HostName }}",
|
||||
"user": "{{ item.User }}",
|
||||
"port": "{{ item.Port }}",
|
||||
"identity_file": "{{ item.IdentityFile }}",
|
||||
}
|
||||
loop: "{{ server.results }}"
|
||||
loop_control:
|
||||
label: "{{ item.Host }}"
|
||||
register: instance_config_dict
|
||||
|
||||
- name: Convert instance config dict to a list
|
||||
ansible.builtin.set_fact:
|
||||
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
|
||||
|
||||
- name: Dump instance config
|
||||
ansible.builtin.copy:
|
||||
content: "{{ instance_conf | to_json | from_json | to_yaml }}"
|
||||
dest: "{{ molecule_instance_config }}"
|
||||
mode: "0600"
|
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
- name: Destroy
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Destroy molecule instance(s) # noqa fqcn[action]
|
||||
vagrant:
|
||||
instances: "{{ molecule_yml.platforms }}"
|
||||
default_box: "{{ molecule_yml.driver.default_box | default('debian/bookworm64') }}"
|
||||
provider_name: "{{ molecule_yml.driver.provider.name | default(omit, true) }}"
|
||||
cachier: "{{ molecule_yml.driver.cachier | default(omit) }}"
|
||||
force_stop: "{{ item.force_stop | default(true) }}"
|
||||
state: destroy
|
||||
register: server
|
||||
|
||||
- name: Populate instance config
|
||||
ansible.builtin.set_fact:
|
||||
instance_conf: {}
|
||||
|
||||
- name: Dump instance config # noqa no-handler
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
# Molecule managed
|
||||
{{ instance_conf | to_json | from_json | to_yaml }}
|
||||
dest: "{{ molecule_instance_config }}"
|
||||
mode: "0600"
|
||||
when: server.changed | bool
|
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
# central configuration entry point for Molecule per scenario
|
||||
dependency:
|
||||
name: galaxy
|
||||
options:
|
||||
requirements-file: requirements.yml
|
||||
driver:
|
||||
name: vagrant
|
||||
provider:
|
||||
name: libvirt
|
||||
provision: false
|
||||
cachier: machine
|
||||
parallel: true
|
||||
default_box: debian/bookworm64
|
||||
platforms:
|
||||
- name: debian-bookworm
|
||||
box: debian/bookworm64
|
||||
memory: 2048
|
||||
cpus: 4
|
||||
hostname: debian-bookworm
|
||||
interfaces:
|
||||
- auto_config: true
|
||||
network_name: private_network
|
||||
type: dhcp
|
||||
instance_raw_config_args: []
|
||||
config_options:
|
||||
ssh.keep_alive: yes
|
||||
ssh.remote_user: 'vagrant'
|
||||
provider_options:
|
||||
video_type: vga
|
||||
provider_raw_config_args: []
|
||||
groups:
|
||||
- molecule
|
||||
provisioner:
|
||||
name: ansible
|
||||
config_options:
|
||||
defaults:
|
||||
vault_password_file: ${HOME}/.config/ansible/vault-id
|
||||
inventory:
|
||||
group_vars:
|
||||
molecule:
|
|
@ -0,0 +1,4 @@
|
|||
custom_base_user_account: 'vagrant'
|
||||
security_firewall_mangle_drop_privatenets: false
|
||||
security_configure_resolve_conf: true
|
||||
global_ip_dualstack: false
|
|
@ -0,0 +1,4 @@
|
|||
collections:
|
||||
- community.docker
|
||||
- ansible.netcommon
|
||||
- kubernetes.core
|
|
@ -0,0 +1,13 @@
|
|||
- name: Retrieve container log
|
||||
ansible.builtin.command:
|
||||
cmd: >-
|
||||
{% raw %}
|
||||
docker logs
|
||||
{% endraw %}
|
||||
{{ item.stdout_lines[0] }}
|
||||
changed_when: false
|
||||
register: logfile_cmd
|
||||
|
||||
- name: Display container log
|
||||
ansible.builtin.fail:
|
||||
msg: "{{ logfile_cmd.stderr }}"
|
Loading…
Add table
Add a link
Reference in a new issue