-
Notifications
You must be signed in to change notification settings - Fork 1
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
Set up molecule testing #3
Changes from all commits
20e7a3a
5a83f5d
4e215ef
a2849a8
693ebc1
af8cb81
8f3e842
4c01e9f
996a2f0
43fa808
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Test provision | ||
on: | ||
pull_request: | ||
paths: | ||
- "roles/provision/**" | ||
|
||
jobs: | ||
molecule: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
scenario: | ||
- centos7 | ||
env: | ||
MOLECULE_RUN_TAGS: provision | ||
PY_COLORS: 1 | ||
ANSIBLE_FORCE_COLOR: 1 | ||
steps: | ||
- name: Check out the codebase | ||
uses: actions/checkout@v4 | ||
with: | ||
path: ansible_collections/mirsg/infrastructure | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Install test dependencies | ||
run: | | ||
sudo apt-get update && sudo apt-get -y install rsync | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install ansible molecule molecule-plugins[docker] docker requests | ||
|
||
- name: Test with molecule | ||
run: | | ||
cd ansible_collections/mirsg/infrastructure/tests | ||
molecule test --scenario-name "${{ matrix.scenario }}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
collections: | ||
- community.general | ||
- ansible.posix | ||
- community.postgresql | ||
- community.docker | ||
- community.crypto |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
options: | ||
force: true | ||
role-file: "${MOLECULE_SCENARIO_DIRECTORY}/../../../meta/requirements.yml" | ||
requirements-file: "${MOLECULE_SCENARIO_DIRECTORY}/../../../meta/requirements.yml" | ||
|
||
driver: | ||
name: docker | ||
|
||
platforms: | ||
- name: instance | ||
hostname: molecule.instnace.local | ||
image: ${MOLECULE_DOCKER_IMAGE:-geerlingguy/docker-centos7-ansible:latest} | ||
required: true | ||
command: "" | ||
cgroupns_mode: host | ||
privileged: true | ||
pre_build_image: ${MOLECULE_PRE_BUILD_IMAGE:-true} | ||
volumes: | ||
- ./molecule-data:/storage/molecule | ||
keep_volumes: false | ||
groups: | ||
- all | ||
- molecule | ||
- centos7 | ||
docker_networks: | ||
- name: molecule | ||
ipam_config: | ||
- subnet: "192.168.56.0/24" | ||
gateway: "192.168.56.1" | ||
networks: | ||
- name: molecule | ||
ipv4_address: "192.168.56.2" | ||
|
||
provisioner: | ||
name: ansible | ||
log: true | ||
config_options: | ||
defaults: | ||
callbacks_enabled: profile_tasks, timer, yaml | ||
tags: | ||
run: ${MOLECULE_RUN_TAGS:-all} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we don't define |
||
inventory: | ||
links: | ||
hosts: ../resources/inventory/hosts.yml | ||
group_vars: ../resources/inventory/group_vars/ | ||
playbooks: | ||
converge: ../resources/converge.yml | ||
env: | ||
ANSIBLE_VERBOSITY: "1" | ||
|
||
verifier: | ||
name: ansible | ||
env: | ||
ANSIBLE_VERBOSITY: "1" | ||
|
||
lint: | | ||
set -e | ||
yamllint . | ||
ansible-lint . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
- name: Provision infrastructure | ||
hosts: all | ||
become: true | ||
gather_facts: true | ||
roles: | ||
- role: mirsg.infrastructure.provision | ||
Check failure on line 7 in tests/molecule/resources/converge.yml GitHub Actions / lintingsyntax-check[specific]
|
||
tags: provision | ||
- role: mirsg.infrastructure.install_python | ||
tags: python | ||
Comment on lines
+7
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we will need to add the other roles here, and probably target specific groups for some of them |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
EXTERNAL_STORAGE_DRIVE: "/storage/molecule" | ||
|
||
# mirsg.infrastructure.provision | ||
server_locale: "en_GB.UTF-8" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
all: | ||
# List of all servers, defining their alias and IP (hostname) | ||
hosts: | ||
# Host for your database server. Variables in host_vars/instance will be available to this host | ||
instance: | ||
hostname: "molecule.instance.local" | ||
ansible_ip: "192.168.56.2" | ||
ansible_port: 22 | ||
|
||
# Ansible groups. Groups allow configuration and variables to be shared between hosts | ||
# Variables in group_vars/all will be shared between all hosts | ||
children: | ||
# All molecule servers. Variables in group_vars/molecule will be shared between these hosts | ||
molecule: | ||
hosts: | ||
instance: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this limits molecule to run only
mirsg.infrastructure.provision