-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: unified prepare playbook for alternative molecule scenarios
Signed-off-by: gardar <[email protected]>
- Loading branch information
Showing
20 changed files
with
196 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
--- | ||
- name: Run local preparation | ||
hosts: localhost | ||
gather_facts: false | ||
vars: | ||
__role_name: "{{ lookup('ansible.builtin.env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" | ||
__binary_name: "{{ __role_name }}" | ||
__binary_url: "{{ lookup('ansible.builtin.vars', __role_name ~ '_binary_url') }}" | ||
__binary_local_dir: "{{ lookup('ansible.builtin.vars', __role_name ~ '_binary_local_dir') }}" | ||
__tls_server_config: "{{ lookup('ansible.builtin.vars', __role_name ~ '_tls_server_config', default={}) }}" | ||
tasks: | ||
- name: "Create local binary directory" | ||
ansible.builtin.file: | ||
path: "{{ __binary_local_dir }}" | ||
state: directory | ||
mode: 0755 | ||
|
||
- name: "Fetch binary" | ||
become: false | ||
ansible.builtin.unarchive: | ||
src: "{{ __binary_url }}" | ||
dest: "{{ __binary_local_dir }}" | ||
remote_src: true | ||
list_files: true | ||
extra_opts: | ||
- "--strip-components=1" | ||
creates: "{{ __binary_local_dir }}/{{ __binary_name }}" | ||
check_mode: false | ||
register: __download_binary | ||
|
||
- name: Generate self signed certificates | ||
when: "'cert_file' in __tls_server_config" | ||
block: | ||
- name: Install pyOpenSSL for certificate generation | ||
ansible.builtin.pip: | ||
name: "pyOpenSSL" | ||
|
||
- name: Create private key | ||
community.crypto.openssl_privatekey: | ||
path: "/tmp/tls.key" | ||
|
||
- name: Create CSR | ||
community.crypto.openssl_csr: | ||
path: "/tmp/tls.csr" | ||
privatekey_path: "/tmp/tls.key" | ||
|
||
- name: Create certificate | ||
community.crypto.x509_certificate: | ||
path: "/tmp/tls.cert" | ||
csr_path: "/tmp/tls.csr" | ||
privatekey_path: "/tmp/tls.key" | ||
provider: selfsigned | ||
|
||
- name: Filter out incompatible distro/ansible version combos | ||
ansible.builtin.add_host: | ||
name: "{{ item }}" | ||
groups: target_hosts | ||
loop: >- | ||
{{ | ||
groups['all'] | ||
| map('extract', hostvars) | ||
| rejectattr('exclude_ansible_vers', 'defined') | ||
| map(attribute='inventory_hostname') | ||
| list | ||
| union( | ||
groups['all'] | ||
| map('extract', hostvars) | ||
| selectattr('exclude_ansible_vers', 'defined') | ||
| rejectattr('exclude_ansible_vers', 'search', ansible_version.major ~ '.' ~ ansible_version.minor) | ||
| map(attribute='inventory_hostname') | ||
| list | ||
) | ||
}} | ||
when: item not in groups['target_hosts'] | ||
changed_when: false | ||
|
||
- name: Run target preparation | ||
hosts: target_hosts | ||
any_errors_fatal: true | ||
vars: | ||
__role_name: "{{ lookup('ansible.builtin.env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" | ||
__tls_server_config: "{{ lookup('ansible.builtin.vars', __role_name ~ '_tls_server_config', default={}) }}" | ||
tasks: | ||
- name: Copy self signed certificates | ||
when: "'cert_file' in __tls_server_config" | ||
block: | ||
- name: "Create cert dir" | ||
ansible.builtin.file: | ||
path: "{{ __tls_server_config.cert_file | dirname }}" | ||
state: directory | ||
owner: root | ||
group: root | ||
mode: u+rwX,g+rwX,o=rX | ||
|
||
- name: "Copy cert and key" | ||
ansible.builtin.copy: | ||
src: "{{ item.src }}" | ||
dest: "{{ item.dest }}" | ||
mode: "{{ item.mode | default('0644') }}" | ||
loop: | ||
- src: "/tmp/tls.cert" | ||
dest: "{{ __tls_server_config.cert_file }}" | ||
- src: "/tmp/tls.key" | ||
dest: "{{ __tls_server_config.key_file }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
--- | ||
provisioner: | ||
playbooks: | ||
prepare: "${MOLECULE_PROJECT_DIRECTORY}/../../.config/molecule/alternative/prepare.yml" | ||
inventory: | ||
group_vars: | ||
all: | ||
fail2ban_exporter_binary_local_dir: "/tmp/fail2ban_exporter-linux-amd64_local" | ||
fail2ban_exporter_web_listen_address: "127.0.1.1:9191" | ||
go_arch: amd64 | ||
fail2ban_exporter_version: 0.10.1 | ||
fail2ban_exporter_binary_url: "https://gitlab.com/hectorjsmith/fail2ban-prometheus-exporter/-/releases/v{{ fail2ban_exporter_version }}/downloads/\ | ||
fail2ban_exporter_{{ fail2ban_exporter_version }}_linux_{{ go_arch }}.tar.gz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
--- | ||
provisioner: | ||
playbooks: | ||
prepare: "${MOLECULE_PROJECT_DIRECTORY}/../../.config/molecule/alternative/prepare.yml" | ||
inventory: | ||
group_vars: | ||
all: | ||
redis_exporter_binary_local_dir: "/tmp/redis_exporter-linux-amd64" | ||
redis_exporter_web_listen_address: "127.0.0.1:8080" | ||
|
||
redis_exporter_tls_server_ca_cert_file: /etc/redis_exporter/tls.cert | ||
redis_exporter_tls_server_cert_file: /etc/redis_exporter/tls.cert | ||
redis_exporter_tls_server_key_file: /etc/redis_exporter/tls.key | ||
redis_exporter_tls_server_config: | ||
cert_file: /etc/redis_exporter/tls.cert | ||
key_file: /etc/redis_exporter/tls.key | ||
redis_exporter_tls_server_cert_file: "{{ redis_exporter_tls_server_config.cert_file }}" | ||
redis_exporter_tls_server_key_file: "{{ redis_exporter_tls_server_config.key_file }}" | ||
go_arch: amd64 | ||
redis_exporter_version: 1.58.0 | ||
redis_exporter_binary_url: "https://github.com/oliver006/redis_exporter/releases/download/v{{\ | ||
\ redis_exporter_version }}/redis_exporter-v{{ redis_exporter_version }}.linux-{{\ | ||
\ go_arch }}.tar.gz" |
Oops, something went wrong.