-
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.
Merge pull request #395 from gardar/update-platforms
fix: remove EOL platforms for current ones
- Loading branch information
Showing
133 changed files
with
534 additions
and
1,713 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,106 @@ | ||
--- | ||
- 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', default='') }}" | ||
__binary_local_dir: "{{ lookup('ansible.builtin.vars', __role_name ~ '_binary_local_dir', default='') }}" | ||
__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 | ||
when: (__binary_local_dir) | ||
|
||
- 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 | ||
when: (__binary_url) | ||
|
||
- 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from __future__ import (absolute_import, division, print_function) | ||
__metaclass__ = type | ||
|
||
import os | ||
import testinfra | ||
|
||
|
||
def get_ansible_version(): | ||
""" | ||
Get the current Ansible version from localhost using the 'debug' module. | ||
Returns: | ||
str: The current Ansible version (major.minor). | ||
""" | ||
localhost = testinfra.get_host( | ||
"ansible://localhost?ansible_inventory=localhost," | ||
) | ||
local_ansible_version = localhost.ansible("debug", "var=ansible_version") | ||
ansible_version = '.'.join( | ||
local_ansible_version['ansible_version']['full'].split('.')[:2] | ||
) | ||
return ansible_version | ||
|
||
|
||
def filter_compatible_hosts(inventory, ansible_version): | ||
""" | ||
Filter hosts based on Ansible version compatibility. | ||
Args: | ||
inventory (str): The inventory file path. | ||
ansible_version (str): The current Ansible version (major.minor). | ||
Returns: | ||
list: A list of compatible hosts that do not have the current Ansible | ||
version in their exclude_ansible_vers hostvars. | ||
""" | ||
ansible_runner = testinfra.utils.ansible_runner.AnsibleRunner(inventory) | ||
all_hosts = ansible_runner.get_hosts('all') | ||
compatible_hosts = [] | ||
|
||
for host in all_hosts: | ||
# Get host variables | ||
host_vars = ansible_runner.get_variables(host) | ||
|
||
# Check if the host should be excluded | ||
if 'exclude_ansible_vers' in host_vars: | ||
excluded_versions = host_vars['exclude_ansible_vers'] | ||
if ansible_version in excluded_versions: | ||
continue | ||
compatible_hosts.append(host) | ||
|
||
return compatible_hosts | ||
|
||
|
||
def get_target_hosts(): | ||
""" | ||
Get the filtered target hosts based on the current Ansible version. | ||
Returns: | ||
list: A list of hosts that are compatible with | ||
the current Ansible version. | ||
""" | ||
# Get current Ansible version | ||
current_ansible_version = get_ansible_version() | ||
|
||
# Get the inventory file from environment | ||
inventory_file = os.environ['MOLECULE_INVENTORY_FILE'] | ||
|
||
# Filter the hosts based on the exclusion criteria | ||
return filter_compatible_hosts(inventory_file, current_ansible_version) |
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 was deleted.
Oops, something went wrong.
6 changes: 2 additions & 4 deletions
6
roles/alertmanager/molecule/alternative/tests/test_alternative.py
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
Oops, something went wrong.