Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add centos test scenario #10

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
release: jammy
- scenario: debian
release: bullseye
- scenario: centos
release: 7

steps:
- name: Check out the codebase.
Expand Down
100 changes: 100 additions & 0 deletions molecule/centos/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
dependency:
name: galaxy
options:
role-file: requirements.yml
requirements-file: requirements.yml
driver:
name: default
options:
managed: false
ansible_connection_options:
ansible_connection: local
platforms:
- name: installer
provisioner:
name: ansible
log: true
env:
ANSIBLE_VERBOSITY: ${MOLECULE_VERBOSITY:-0}
config_options:
defaults:
interpreter_python: auto_silent
callbacks_enabled: ansible.posix.profile_tasks
callback_whitelist: profile_tasks, timer, yaml
playbooks:
prepare: ../common/prepare.yml
create: ../common/create.yml
converge: ../common/converge.yml
verify: ../common/verify.yml
cleanup: ../common/cleanup.yml
side_effect: ../common/reboot.yml
inventory:
hosts:
all:
vars:
growfs_device_filter: "vd.*"
molecule_scenario: "${MOLECULE_SCENARIO}"
molecule_distro: "{{ lookup('env', 'MOLECULE_DISTRO', default='7') }}"
molecule_iso: "{{ lookup('env', 'MOLECULE_ISO', default='http://mirrors.ucr.ac.cr/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-Minimal-2009.iso') }}"
molecule_debug: "{{ lookup('env', 'GITHUB_ACTIONS', default='false') | bool }}"
cache_dir: "/tmp/{{ molecule_distro }}"
output_dir: "{{ lookup('env', 'MOLECULE_OUTPUT_DIR', default='/tmp/logs') }}"

molecule_net: "{{ lookup('env', 'MOLECULE_NET', default='192.168.253.0/24') }}"
bridge_net: "{{ molecule_net | ansible.utils.ipv4('network/prefix') }}"
bridge_host: "{{ bridge_net | ansible.utils.nthhost(1) }}"
bridge_prefix: "{{ bridge_net | ansible.utils.ipaddr('prefix') }}"
bridge_name: "{{ molecule_distro }}br1"
bridge_iface: "{{ molecule_distro }}0"

kvm_keypair: "{{ cache_dir }}/kvm_key"
ansible_ssh_common_args: '-o StrictHostKeyChecking=no'

iso_installer:
dest: "file://{{ cache_dir }}/{{ molecule_distro }}.iso"
url: "{{ molecule_iso }}"

guests:
- installer_hostname: "{{ molecule_distro }}-autopart-10g"
installer_disk_size: "{{ 10*(1024**3) }}"
installer_interface:
static: true
ipaddress: "{{ bridge_net | ansible.utils.nthhost(2) }}"
network: "{{ bridge_net | ansible.utils.ipaddr('network') }}"
netmask: "{{ bridge_net | ansible.utils.ipaddr('netmask') }}"
gateway: "{{ bridge_host }}"
nameservers:
- 1.1.1.1
- 8.8.8.8
installer_ks_partitioning: autopart
installer_partitioning_method: autopart

- installer_hostname: "{{ molecule_distro }}-static-10g"
installer_disk_size: "{{ 10*(1024**3) }}"
installer_interface:
static: true
ipaddress: "{{ bridge_net | ansible.utils.nthhost(3) }}"
network: "{{ bridge_net | ansible.utils.ipaddr('network') }}"
netmask: "{{ bridge_net | ansible.utils.ipaddr('netmask') }}"
gateway: "{{ bridge_host }}"
nameservers:
- 1.1.1.1
- 8.8.8.8
installer_partitioning_method: static
installer_ks_partitioning: |
part /boot --fstype ext4 --size=2048
part swap --asprimary --size=1024
part / --type plain --fstype ext4 --size=1 --grow

verifier:
name: ansible
scenario:
test_sequence:
- dependency
- create
- prepare
- converge
- side_effect
- verify
- cleanup
21 changes: 21 additions & 0 deletions molecule/common/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,27 @@
loop: "{{ guest_info }}"
when: molecule_scenario == "debian"

- name: Build centos installer isos
ansible.builtin.include_role:
name: nephelaiio.centos_installer
vars:
centos_installer_interface_name: enp1s0
centos_installer_target_dir: "{{ cache_dir }}"
centos_installer_image: "{{ iso_installer.dest }}"
centos_installer_hostname: "{{ guest.installer_hostname }}"
centos_installer_username: molecule
centos_installer_password: "{{ 'molecule' | password_hash('sha512') }}"
centos_installer_sshkey:
- "{{ lookup('file', kvm_keypair + '.pub') }}"
centos_installer_interface: "{{ guest.installer_interface }}"
centos_installer_ks_keyboard: 'us'
centos_installer_ks_partitioning: "{{ guest.installer_ks_partitioning }}"
loop_control:
loop_var: guest
label: "{{ guest.installer_hostname }}"
loop: "{{ guest_info }}"
when: molecule_scenario == "centos"

- name: Create KVM guest disks
ansible.builtin.command: "qemu-img create {{ guest_disk }} {{ guest_disk_size }}"
args:
Expand Down
2 changes: 1 addition & 1 deletion molecule/debian/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ provisioner:
all:
vars:
growfs_device_filter: "vd.*"
molecule_scenario: "${MOLECULE_SCENARIO_NAME}"
molecule_scenario: "${MOLECULE_SCENARIO}"
molecule_distro: "{{ lookup('env', 'MOLECULE_DISTRO', default='bullseye') }}"
molecule_iso: "{{ lookup('env', 'MOLECULE_ISO', default='https://cdimage.debian.org/mirror/cdimage/archive/11.8.0/amd64/iso-dvd/debian-11.8.0-amd64-DVD-1.iso') }}"
molecule_debug: "{{ lookup('env', 'GITHUB_ACTIONS', default='false') | bool }}"
Expand Down
2 changes: 1 addition & 1 deletion molecule/ubuntu/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ provisioner:
all:
vars:
growfs_device_filter: "vd.*"
molecule_scenario: "${MOLECULE_SCENARIO_NAME}"
molecule_scenario: "${MOLECULE_SCENARIO}"
molecule_distro: "{{ lookup('env', 'MOLECULE_DISTRO', default='jammy') }}"
molecule_iso: "{{ lookup('env', 'MOLECULE_ISO', default='https://releases.ubuntu.com/jammy/ubuntu-22.04.3-live-server-amd64.iso') }}"
molecule_debug: "{{ lookup('env', 'GITHUB_ACTIONS', default='false') | bool }}"
Expand Down