feat: add test for Rocky Linux 8 (#1)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
43c7ff76d3
commit
1edc1aae5f
@ -71,7 +71,7 @@ local PipelineDeployment(scenario='centos7') = {
|
||||
'linting',
|
||||
],
|
||||
trigger: {
|
||||
ref: ['refs/heads/master', 'refs/tags/**'],
|
||||
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
|
||||
},
|
||||
};
|
||||
|
||||
@ -116,6 +116,7 @@ local PipelineDocumentation = {
|
||||
},
|
||||
depends_on: [
|
||||
'testing-centos7',
|
||||
'testing-rocky8',
|
||||
],
|
||||
};
|
||||
|
||||
@ -154,6 +155,7 @@ local PipelineNotification = {
|
||||
[
|
||||
PipelineLinting,
|
||||
PipelineDeployment(scenario='centos7'),
|
||||
PipelineDeployment(scenario='rocky8'),
|
||||
PipelineDocumentation,
|
||||
PipelineNotification,
|
||||
]
|
||||
|
37
.drone.yml
37
.drone.yml
@ -62,6 +62,40 @@ trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
depends_on:
|
||||
- linting
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
name: testing-rocky8
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
concurrency:
|
||||
limit: 1
|
||||
|
||||
workspace:
|
||||
base: /drone/src
|
||||
path: ${DRONE_REPO_NAME}
|
||||
|
||||
steps:
|
||||
- name: ansible-molecule
|
||||
image: thegeeklab/molecule:3
|
||||
commands:
|
||||
- molecule test -s rocky8
|
||||
environment:
|
||||
HCLOUD_TOKEN:
|
||||
from_secret: hcloud_token
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/heads/master
|
||||
- refs/tags/**
|
||||
- refs/pull/**
|
||||
|
||||
depends_on:
|
||||
- linting
|
||||
@ -108,6 +142,7 @@ trigger:
|
||||
|
||||
depends_on:
|
||||
- testing-centos7
|
||||
- testing-rocky8
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
@ -147,6 +182,6 @@ depends_on:
|
||||
|
||||
---
|
||||
kind: signature
|
||||
hmac: 18aff92f85fff5755d056ea050564f6cfd71c2c8ac6ae3a53c93d2dfc907bb77
|
||||
hmac: 9b6ecccea486cb36e2ba8dfa108490b73b053fef8cdb510b1fa9af64762b15a3
|
||||
|
||||
...
|
||||
|
@ -1,9 +1,10 @@
|
||||
---
|
||||
ldap_proxy_base_dir: /etc/openldap
|
||||
ldap_proxy_urls:
|
||||
- "ldapi:/// ldap:///"
|
||||
ldap_proxy_options: []
|
||||
|
||||
ldap_proxy_base_dir: /etc/openldap
|
||||
|
||||
ldap_proxy_tls_enabled: False
|
||||
ldap_proxy_tls_cert_source: mycert.pem
|
||||
ldap_proxy_tls_key_source: mykey.pem
|
||||
@ -21,8 +22,8 @@ ldap_proxy_loglevel: 0
|
||||
ldap_proxy_acl_file: "{{ ldap_proxy_base_dir }}/slapd.access"
|
||||
ldap_proxy_acls:
|
||||
- access_to:
|
||||
- '*'
|
||||
- "*"
|
||||
access_by:
|
||||
- '* read'
|
||||
- "* read"
|
||||
|
||||
ldap_proxy_custom_schemas: []
|
||||
|
@ -4,6 +4,7 @@
|
||||
service:
|
||||
state: restarted
|
||||
name: slapd
|
||||
daemon_reload: yes
|
||||
listen: __slapd_restart
|
||||
become: True
|
||||
become_user: root
|
||||
|
@ -1 +1 @@
|
||||
centos7
|
||||
rocky8
|
5
molecule/rocky8/converge.yml
Normal file
5
molecule/rocky8/converge.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Converge
|
||||
hosts: all
|
||||
roles:
|
||||
- role: xoxys.ldap_proxy
|
120
molecule/rocky8/create.yml
Normal file
120
molecule/rocky8/create.yml
Normal file
@ -0,0 +1,120 @@
|
||||
---
|
||||
- name: Create
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
no_log: "{{ molecule_no_log }}"
|
||||
vars:
|
||||
ssh_port: 22
|
||||
ssh_user: root
|
||||
ssh_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/ssh_key"
|
||||
tasks:
|
||||
- name: Create SSH key
|
||||
user:
|
||||
name: "{{ lookup('env', 'USER') }}"
|
||||
generate_ssh_key: true
|
||||
ssh_key_file: "{{ ssh_path }}"
|
||||
force: true
|
||||
register: generated_ssh_key
|
||||
|
||||
- name: Register the SSH key name
|
||||
set_fact:
|
||||
ssh_key_name: "molecule-generated-{{ 12345 | random | to_uuid }}"
|
||||
|
||||
- name: Register SSH key for test instance(s)
|
||||
hcloud_ssh_key:
|
||||
name: "{{ ssh_key_name }}"
|
||||
public_key: "{{ generated_ssh_key.ssh_public_key }}"
|
||||
state: present
|
||||
|
||||
- name: Create molecule instance(s)
|
||||
hcloud_server:
|
||||
name: "{{ item.name }}"
|
||||
server_type: "{{ item.server_type }}"
|
||||
ssh_keys:
|
||||
- "{{ ssh_key_name }}"
|
||||
image: "{{ item.image }}"
|
||||
location: "{{ item.location | default(omit) }}"
|
||||
datacenter: "{{ item.datacenter | default(omit) }}"
|
||||
user_data: "{{ item.user_data | default(omit) }}"
|
||||
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
|
||||
state: present
|
||||
register: server
|
||||
loop: "{{ molecule_yml.platforms }}"
|
||||
async: 7200
|
||||
poll: 0
|
||||
|
||||
- name: Wait for instance(s) creation to complete
|
||||
async_status:
|
||||
jid: "{{ item.ansible_job_id }}"
|
||||
register: hetzner_jobs
|
||||
until: hetzner_jobs.finished
|
||||
retries: 300
|
||||
loop: "{{ server.results }}"
|
||||
|
||||
- name: Create volume(s)
|
||||
hcloud_volume:
|
||||
name: "{{ item.name }}"
|
||||
server: "{{ item.name }}"
|
||||
location: "{{ item.location | default(omit) }}"
|
||||
size: "{{ item.volume_size | default(10) }}"
|
||||
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
|
||||
state: "present"
|
||||
loop: "{{ molecule_yml.platforms }}"
|
||||
when: item.volume | default(False) | bool
|
||||
register: volumes
|
||||
async: 7200
|
||||
poll: 0
|
||||
|
||||
- name: Wait for volume(s) creation to complete
|
||||
async_status:
|
||||
jid: "{{ item.ansible_job_id }}"
|
||||
register: hetzner_volumes
|
||||
until: hetzner_volumes.finished
|
||||
retries: 300
|
||||
when: volumes.changed
|
||||
loop: "{{ volumes.results }}"
|
||||
|
||||
# Mandatory configuration for Molecule to function.
|
||||
|
||||
- name: Populate instance config dict
|
||||
set_fact:
|
||||
instance_conf_dict:
|
||||
{
|
||||
"instance": "{{ item.hcloud_server.name }}",
|
||||
"ssh_key_name": "{{ ssh_key_name }}",
|
||||
"address": "{{ item.hcloud_server.ipv4_address }}",
|
||||
"user": "{{ ssh_user }}",
|
||||
"port": "{{ ssh_port }}",
|
||||
"identity_file": "{{ ssh_path }}",
|
||||
"volume": "{{ item.item.item.volume | default(False) | bool }}",
|
||||
}
|
||||
loop: "{{ hetzner_jobs.results }}"
|
||||
register: instance_config_dict
|
||||
when: server.changed | bool
|
||||
|
||||
- name: Convert instance config dict to a list
|
||||
set_fact:
|
||||
instance_conf: "{{ instance_config_dict.results | map(attribute='ansible_facts.instance_conf_dict') | list }}"
|
||||
when: server.changed | bool
|
||||
|
||||
- name: Dump instance config
|
||||
copy:
|
||||
content: |
|
||||
# Molecule managed
|
||||
|
||||
{{ instance_conf | to_nice_yaml(indent=2) }}
|
||||
dest: "{{ molecule_instance_config }}"
|
||||
when: server.changed | bool
|
||||
|
||||
- name: Wait for SSH
|
||||
wait_for:
|
||||
port: "{{ ssh_port }}"
|
||||
host: "{{ item.address }}"
|
||||
search_regex: SSH
|
||||
delay: 10
|
||||
loop: "{{ lookup('file', molecule_instance_config) | from_yaml }}"
|
||||
|
||||
- name: Wait for VM to settle down
|
||||
pause:
|
||||
seconds: 30
|
78
molecule/rocky8/destroy.yml
Normal file
78
molecule/rocky8/destroy.yml
Normal file
@ -0,0 +1,78 @@
|
||||
---
|
||||
- name: Destroy
|
||||
hosts: localhost
|
||||
connection: local
|
||||
gather_facts: false
|
||||
no_log: "{{ molecule_no_log }}"
|
||||
tasks:
|
||||
- name: Check existing instance config file
|
||||
stat:
|
||||
path: "{{ molecule_instance_config }}"
|
||||
register: cfg
|
||||
|
||||
- name: Populate the instance config
|
||||
set_fact:
|
||||
instance_conf: "{{ (lookup('file', molecule_instance_config) | from_yaml) if cfg.stat.exists else [] }}"
|
||||
|
||||
- name: Destroy molecule instance(s)
|
||||
hcloud_server:
|
||||
name: "{{ item.instance }}"
|
||||
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
|
||||
state: absent
|
||||
register: server
|
||||
loop: "{{ instance_conf }}"
|
||||
async: 7200
|
||||
poll: 0
|
||||
|
||||
- name: Wait for instance(s) deletion to complete
|
||||
async_status:
|
||||
jid: "{{ item.ansible_job_id }}"
|
||||
register: hetzner_jobs
|
||||
until: hetzner_jobs.finished
|
||||
retries: 300
|
||||
loop: "{{ server.results }}"
|
||||
|
||||
- pause:
|
||||
seconds: 5
|
||||
|
||||
- name: Destroy volume(s)
|
||||
hcloud_volume:
|
||||
name: "{{ item.instance }}"
|
||||
server: "{{ item.instance }}"
|
||||
api_token: "{{ lookup('env', 'HCLOUD_TOKEN') }}"
|
||||
state: "absent"
|
||||
register: volumes
|
||||
loop: "{{ instance_conf }}"
|
||||
when: item.volume | default(False) | bool
|
||||
async: 7200
|
||||
poll: 0
|
||||
|
||||
- name: Wait for volume(s) deletion to complete
|
||||
async_status:
|
||||
jid: "{{ item.ansible_job_id }}"
|
||||
register: hetzner_volumes
|
||||
until: hetzner_volumes.finished
|
||||
retries: 300
|
||||
when: volumes.changed
|
||||
loop: "{{ volumes.results }}"
|
||||
|
||||
- name: Remove registered SSH key
|
||||
hcloud_ssh_key:
|
||||
name: "{{ instance_conf[0].ssh_key_name }}"
|
||||
state: absent
|
||||
when: (instance_conf | default([])) | length > 0
|
||||
|
||||
# Mandatory configuration for Molecule to function.
|
||||
|
||||
- name: Populate instance config
|
||||
set_fact:
|
||||
instance_conf: {}
|
||||
|
||||
- name: Dump instance config
|
||||
copy:
|
||||
content: |
|
||||
# Molecule managed
|
||||
|
||||
{{ instance_conf | to_nice_yaml(indent=2) }}
|
||||
dest: "{{ molecule_instance_config }}"
|
||||
when: server.changed | bool
|
24
molecule/rocky8/molecule.yml
Normal file
24
molecule/rocky8/molecule.yml
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
dependency:
|
||||
name: galaxy
|
||||
options:
|
||||
role-file: molecule/requirements.yml
|
||||
requirements-file: molecule/requirements.yml
|
||||
env:
|
||||
ANSIBLE_GALAXY_DISPLAY_PROGRESS: "false"
|
||||
driver:
|
||||
name: delegated
|
||||
platforms:
|
||||
- name: rocky8-ldap-proxy
|
||||
image: rocky-8
|
||||
server_type: cx11
|
||||
lint: |
|
||||
/usr/local/bin/flake8
|
||||
provisioner:
|
||||
name: ansible
|
||||
env:
|
||||
ANSIBLE_FILTER_PLUGINS: ${ANSIBLE_FILTER_PLUGINS:-./plugins/filter}
|
||||
ANSIBLE_LIBRARY: ${ANSIBLE_LIBRARY:-./library}
|
||||
log: False
|
||||
verifier:
|
||||
name: testinfra
|
15
molecule/rocky8/prepare.yml
Normal file
15
molecule/rocky8/prepare.yml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: Prepare
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Bootstrap python for Ansible
|
||||
raw: |
|
||||
command -v python3 python || (
|
||||
(test -e /usr/bin/dnf && sudo dnf install -y python3) ||
|
||||
(test -e /usr/bin/apt && (apt -y update && apt install -y python-minimal)) ||
|
||||
(test -e /usr/bin/yum && sudo yum -y -qq install python3) ||
|
||||
echo "Warning: Python not boostrapped due to unknown platform."
|
||||
)
|
||||
become: true
|
||||
changed_when: false
|
20
molecule/rocky8/tests/test_default.py
Normal file
20
molecule/rocky8/tests/test_default.py
Normal file
@ -0,0 +1,20 @@
|
||||
import os
|
||||
|
||||
import testinfra.utils.ansible_runner
|
||||
|
||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||
os.environ["MOLECULE_INVENTORY_FILE"]
|
||||
).get_hosts("all")
|
||||
|
||||
|
||||
def test_ldap_proxy_is_installed(host):
|
||||
ldap_proxy_server = host.package("openldap-servers")
|
||||
ldap_proxy_client = host.package("openldap-clients")
|
||||
assert ldap_proxy_server.is_installed
|
||||
assert ldap_proxy_client.is_installed
|
||||
|
||||
|
||||
def test_ldap_proxy_running_and_enabled(host):
|
||||
ldap_proxy = host.service("slapd")
|
||||
assert ldap_proxy.is_running
|
||||
assert ldap_proxy.is_enabled
|
@ -1,5 +1,32 @@
|
||||
---
|
||||
- include_vars: "{{ var_files }}"
|
||||
vars:
|
||||
var_files: "{{ lookup('first_found', params, errors='ignore') }}"
|
||||
params:
|
||||
files:
|
||||
- "{{ ansible_lsb.id | default('') | lower }}.yml"
|
||||
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version }}.yml"
|
||||
- "{{ ansible_os_family | lower }}.yml"
|
||||
- default.yml
|
||||
paths:
|
||||
- "vars"
|
||||
when: var_files
|
||||
|
||||
- include_tasks: overwrites.yml
|
||||
- include_tasks: setup.yml
|
||||
|
||||
- include_tasks: "{{ task_files }}"
|
||||
vars:
|
||||
task_files: "{{ lookup('first_found', params, errors='ignore') }}"
|
||||
params:
|
||||
files:
|
||||
- "setup_{{ ansible_lsb.id | default('') | lower }}.yml"
|
||||
- "setup_{{ ansible_os_family | lower }}{{ ansible_distribution_major_version }}.yml"
|
||||
- "setup_{{ ansible_os_family | lower }}.yml"
|
||||
paths:
|
||||
- "tasks"
|
||||
when: task_files
|
||||
|
||||
- import_tasks: tls.yml
|
||||
when: ldap_proxy_tls_enabled | bool
|
||||
- include_tasks: post_tasks.yml
|
||||
|
5
tasks/overwrites.yml
Normal file
5
tasks/overwrites.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Define ldap_proxy_enablerepo
|
||||
set_fact:
|
||||
ldap_proxy_enablerepo: "{{ __ldap_proxy_enablerepo | list }}"
|
||||
when: ldap_proxy_enablerepo is not defined
|
@ -4,5 +4,6 @@
|
||||
state: started
|
||||
enabled: yes
|
||||
name: slapd
|
||||
daemon_reload: yes
|
||||
become: True
|
||||
become_user: root
|
||||
|
@ -3,6 +3,7 @@
|
||||
- name: Install required packages
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
enablerepo: "{{ ldap_proxy_enablerepo }}"
|
||||
state: present
|
||||
loop:
|
||||
- openldap-servers
|
||||
|
7
tasks/setup_redhat8.yml
Normal file
7
tasks/setup_redhat8.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: Setup custom systemd service
|
||||
template:
|
||||
src: etc/systemd/system/slapd.service.j2
|
||||
dest: "/etc/systemd/system/slapd.service"
|
||||
mode: 0644
|
||||
notify: __slapd_restart
|
6
templates/etc/systemd/system/slapd.service.j2
Normal file
6
templates/etc/systemd/system/slapd.service.j2
Normal file
@ -0,0 +1,6 @@
|
||||
[Service]
|
||||
Type=forking
|
||||
Environment="SLAPD_URLS=ldap:/// ldaps:/// ldapi:///" "SLAPD_OPTIONS="
|
||||
EnvironmentFile=/etc/sysconfig/slapd
|
||||
ExecStart=
|
||||
ExecStart=/usr/sbin/slapd -u ldap -h ${SLAPD_URLS} $SLAPD_OPTIONS
|
2
vars/default.yml
Normal file
2
vars/default.yml
Normal file
@ -0,0 +1,2 @@
|
||||
---
|
||||
__ldap_proxy_enablerepo: []
|
3
vars/redhat-8.yml
Normal file
3
vars/redhat-8.yml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
__ldap_proxy_enablerepo:
|
||||
- plus
|
Loading…
Reference in New Issue
Block a user