Compare commits
2 Commits
main
...
test-rocky
Author | SHA1 | Date | |
---|---|---|---|
d2b8452e3a | |||
8fa5677965 |
@ -15,18 +15,18 @@ local PipelineLinting = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'python-format',
|
name: 'python-format',
|
||||||
image: 'python:3.11',
|
image: 'python:3.9',
|
||||||
environment: {
|
environment: {
|
||||||
PY_COLORS: 1,
|
PY_COLORS: 1,
|
||||||
},
|
},
|
||||||
commands: [
|
commands: [
|
||||||
'pip install -qq yapf',
|
'pip install -qq yapf',
|
||||||
'[ -z "$(find . -type f -name *.py)" ] || (yapf -rd ./)',
|
'[ -z "$(find . -type f -name *.py)" ] || (yapf -rd ./)',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'python-flake8',
|
name: 'python-flake8',
|
||||||
image: 'python:3.11',
|
image: 'python:3.9',
|
||||||
environment: {
|
environment: {
|
||||||
PY_COLORS: 1,
|
PY_COLORS: 1,
|
||||||
},
|
},
|
||||||
@ -37,7 +37,7 @@ local PipelineLinting = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
trigger: {
|
trigger: {
|
||||||
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ local PipelineDeployment(scenario='centos7') = {
|
|||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
name: 'ansible-molecule',
|
name: 'ansible-molecule',
|
||||||
image: 'thegeeklab/molecule:4',
|
image: 'thegeeklab/molecule:3',
|
||||||
environment: {
|
environment: {
|
||||||
HCLOUD_TOKEN: { from_secret: 'hcloud_token' },
|
HCLOUD_TOKEN: { from_secret: 'hcloud_token' },
|
||||||
},
|
},
|
||||||
@ -71,7 +71,7 @@ local PipelineDeployment(scenario='centos7') = {
|
|||||||
'linting',
|
'linting',
|
||||||
],
|
],
|
||||||
trigger: {
|
trigger: {
|
||||||
ref: ['refs/heads/main', 'refs/tags/**'],
|
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -107,15 +107,16 @@ local PipelineDocumentation = {
|
|||||||
target_branch: 'docs',
|
target_branch: 'docs',
|
||||||
},
|
},
|
||||||
when: {
|
when: {
|
||||||
ref: ['refs/heads/main'],
|
ref: ['refs/heads/master'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
trigger: {
|
trigger: {
|
||||||
ref: ['refs/heads/main', 'refs/tags/**', 'refs/pull/**'],
|
ref: ['refs/heads/master', 'refs/tags/**', 'refs/pull/**'],
|
||||||
},
|
},
|
||||||
depends_on: [
|
depends_on: [
|
||||||
'testing-centos7',
|
'testing-centos7',
|
||||||
|
'testing-rocky8',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -136,7 +137,7 @@ local PipelineNotification = {
|
|||||||
settings: {
|
settings: {
|
||||||
homeserver: { from_secret: 'matrix_homeserver' },
|
homeserver: { from_secret: 'matrix_homeserver' },
|
||||||
roomid: { from_secret: 'matrix_roomid' },
|
roomid: { from_secret: 'matrix_roomid' },
|
||||||
template: 'Status: **{{ .Build.Status }}**<br/> Build: [{{ .Repo.Owner }}/{{ .Repo.Name }}]({{ .Build.Link }}){{ if .Build.Branch }} ({{ .Build.Branch }}){{ end }} by {{ .Commit.Author }}<br/> Message: {{ .Commit.Message.Title }}',
|
template: 'Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}',
|
||||||
username: { from_secret: 'matrix_username' },
|
username: { from_secret: 'matrix_username' },
|
||||||
password: { from_secret: 'matrix_password' },
|
password: { from_secret: 'matrix_password' },
|
||||||
},
|
},
|
||||||
@ -147,13 +148,14 @@ local PipelineNotification = {
|
|||||||
],
|
],
|
||||||
trigger: {
|
trigger: {
|
||||||
status: ['success', 'failure'],
|
status: ['success', 'failure'],
|
||||||
ref: ['refs/heads/main', 'refs/tags/**'],
|
ref: ['refs/heads/master', 'refs/tags/**'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
[
|
[
|
||||||
PipelineLinting,
|
PipelineLinting,
|
||||||
PipelineDeployment(scenario='centos7'),
|
PipelineDeployment(scenario='centos7'),
|
||||||
|
PipelineDeployment(scenario='rocky8'),
|
||||||
PipelineDocumentation,
|
PipelineDocumentation,
|
||||||
PipelineNotification,
|
PipelineNotification,
|
||||||
]
|
]
|
||||||
|
57
.drone.yml
57
.drone.yml
@ -13,15 +13,15 @@ steps:
|
|||||||
- ansible-later
|
- ansible-later
|
||||||
|
|
||||||
- name: python-format
|
- name: python-format
|
||||||
image: python:3.11
|
image: python:3.9
|
||||||
commands:
|
commands:
|
||||||
- pip install -qq yapf
|
- pip install -qq yapf
|
||||||
- "[ -z \"$(find . -type f -name *.py)\" ] || (yapf -rd ./)"
|
- "[ -z \"$(find . -type f -name *.py)\" ] || (yapf -rd ./)"
|
||||||
environment:
|
environment:
|
||||||
PY_COLORS: 1
|
PY_COLORS: 1
|
||||||
|
|
||||||
- name: python-flake8
|
- name: python-flake8
|
||||||
image: python:3.11
|
image: python:3.9
|
||||||
commands:
|
commands:
|
||||||
- pip install -qq flake8
|
- pip install -qq flake8
|
||||||
- flake8
|
- flake8
|
||||||
@ -30,7 +30,7 @@ steps:
|
|||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/main
|
- refs/heads/master
|
||||||
- refs/tags/**
|
- refs/tags/**
|
||||||
- refs/pull/**
|
- refs/pull/**
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ workspace:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: ansible-molecule
|
- name: ansible-molecule
|
||||||
image: thegeeklab/molecule:4
|
image: thegeeklab/molecule:3
|
||||||
commands:
|
commands:
|
||||||
- molecule test -s centos7
|
- molecule test -s centos7
|
||||||
environment:
|
environment:
|
||||||
@ -60,8 +60,42 @@ steps:
|
|||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/main
|
- refs/heads/master
|
||||||
- refs/tags/**
|
- 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:
|
depends_on:
|
||||||
- linting
|
- linting
|
||||||
@ -98,16 +132,17 @@ steps:
|
|||||||
from_secret: gitea_username
|
from_secret: gitea_username
|
||||||
when:
|
when:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/main
|
- refs/heads/master
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/main
|
- refs/heads/master
|
||||||
- refs/tags/**
|
- refs/tags/**
|
||||||
- refs/pull/**
|
- refs/pull/**
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- testing-centos7
|
- testing-centos7
|
||||||
|
- testing-rocky8
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
@ -130,13 +165,13 @@ steps:
|
|||||||
from_secret: matrix_password
|
from_secret: matrix_password
|
||||||
roomid:
|
roomid:
|
||||||
from_secret: matrix_roomid
|
from_secret: matrix_roomid
|
||||||
template: "Status: **{{ .Build.Status }}**<br/> Build: [{{ .Repo.Owner }}/{{ .Repo.Name }}]({{ .Build.Link }}){{ if .Build.Branch }} ({{ .Build.Branch }}){{ end }} by {{ .Commit.Author }}<br/> Message: {{ .Commit.Message.Title }}"
|
template: "Status: **{{ build.Status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.Link }}){{#if build.Branch}} ({{ build.Branch }}){{/if}} by {{ commit.Author }}<br/> Message: {{ commit.Message.Title }}"
|
||||||
username:
|
username:
|
||||||
from_secret: matrix_username
|
from_secret: matrix_username
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
ref:
|
ref:
|
||||||
- refs/heads/main
|
- refs/heads/master
|
||||||
- refs/tags/**
|
- refs/tags/**
|
||||||
status:
|
status:
|
||||||
- success
|
- success
|
||||||
@ -147,6 +182,6 @@ depends_on:
|
|||||||
|
|
||||||
---
|
---
|
||||||
kind: signature
|
kind: signature
|
||||||
hmac: dd95cc1640a1d0d02e331cb43826daca6f88f1f37f0c55b7f01edfd7f167e3f0
|
hmac: 590c589475035ffcf54d40facf1277941a2673ba58c636367159d9b6729ed9fe
|
||||||
|
|
||||||
...
|
...
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -9,5 +9,3 @@ __pycache__/
|
|||||||
*.py[cod]
|
*.py[cod]
|
||||||
*$py.class
|
*$py.class
|
||||||
|
|
||||||
# ---> Docs
|
|
||||||
/_docs
|
|
||||||
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2022 Robert Kaussow <mail@thegeeklab.de>
|
Copyright (c) 2021 Robert Kaussow <mail@thegeeklab.de>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -8,7 +8,7 @@ galaxy_info:
|
|||||||
# @meta description: >
|
# @meta description: >
|
||||||
# [![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.vaultwarden_ldap_docker)
|
# [![Source Code](https://img.shields.io/badge/gitea-source%20code-blue?logo=gitea&logoColor=white)](https://gitea.rknet.org/ansible/xoxys.vaultwarden_ldap_docker)
|
||||||
# [![Build Status](https://img.shields.io/drone/build/ansible/xoxys.vaultwarden_ldap_docker?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.vaultwarden_ldap_docker)
|
# [![Build Status](https://img.shields.io/drone/build/ansible/xoxys.vaultwarden_ldap_docker?logo=drone&server=https%3A%2F%2Fdrone.rknet.org)](https://drone.rknet.org/ansible/xoxys.vaultwarden_ldap_docker)
|
||||||
# [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitea.rknet.org/ansible/xoxys.vaultwarden_ldap_docker/src/branch/main/LICENSE)
|
# [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitea.rknet.org/ansible/xoxys.vaultwarden_ldap_docker/src/branch/master/LICENSE)
|
||||||
#
|
#
|
||||||
# Role to setup a [Vaultwarden LDAP](https://gitea.rknet.org/docker/vaultwarden-ldap) Sync Service
|
# Role to setup a [Vaultwarden LDAP](https://gitea.rknet.org/docker/vaultwarden-ldap) Sync Service
|
||||||
# for [Vaultwarden](https://github.com/dani-garcia/vaultwarden) password safe.
|
# for [Vaultwarden](https://github.com/dani-garcia/vaultwarden) password safe.
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
vars:
|
vars:
|
||||||
dockerengine_packages_extra:
|
dockerengine_packages_extra:
|
||||||
- epel-release
|
- epel-release
|
||||||
- python-pip
|
- python3-pip
|
||||||
- python-virtualenv
|
- python3-virtualenv
|
||||||
dockerengine_networks:
|
dockerengine_networks:
|
||||||
- name: vaultwarden_default
|
- name: vaultwarden_default
|
||||||
vaultwarden_ldap_service_stopped: True
|
vaultwarden_ldap_service_stopped: True
|
||||||
|
@ -1 +1 @@
|
|||||||
centos7
|
rocky8
|
@ -7,4 +7,4 @@ roles:
|
|||||||
- src: https://gitea.rknet.org/ansible/xoxys.docker_engine.git
|
- src: https://gitea.rknet.org/ansible/xoxys.docker_engine.git
|
||||||
name: xoxys.docker_engine
|
name: xoxys.docker_engine
|
||||||
scm: git
|
scm: git
|
||||||
version: main
|
version: master
|
||||||
|
21
molecule/rocky8/converge.yml
Normal file
21
molecule/rocky8/converge.yml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
- name: Converge
|
||||||
|
hosts: all
|
||||||
|
environment:
|
||||||
|
PYTHONPATH: /opt/python2/ansible-deps/lib/python2.7/site-packages
|
||||||
|
vars:
|
||||||
|
dockerengine_packages_extra:
|
||||||
|
- epel-release
|
||||||
|
- python3-pip
|
||||||
|
- python3-virtualenv
|
||||||
|
dockerengine_networks:
|
||||||
|
- name: vaultwarden_default
|
||||||
|
vaultwarden_ldap_service_stopped: True
|
||||||
|
vaultwarden_ldap_host: ldap.example.com
|
||||||
|
vaultwarden_ldap_bind_dn: "uid=dummy,cn=users,dc=example,dc=com"
|
||||||
|
vaultwarden_ldap_bind_password: dummy
|
||||||
|
vaultwarden_ldap_search_base_dn: "ou=Users,dc=example,dc=com"
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: xoxys.docker_engine
|
||||||
|
- role: xoxys.vaultwarden_ldap_docker
|
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-vaultwarden-ldap
|
||||||
|
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
|
12
molecule/rocky8/tests/test_default.py
Normal file
12
molecule/rocky8/tests/test_default.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import testinfra.utils.ansible_runner
|
||||||
|
|
||||||
|
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
||||||
|
os.environ["MOLECULE_INVENTORY_FILE"]
|
||||||
|
).get_hosts("all")
|
||||||
|
|
||||||
|
|
||||||
|
def test_vaultwarden_ldap_compose_file(host):
|
||||||
|
f = host.file('/var/lib/docker/services/vaultwarden_ldap/docker-compose.yml')
|
||||||
|
assert f.exists
|
Loading…
Reference in New Issue
Block a user