Skip to content
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

OPSEXP-2147 Drop helper_modules role #956

Merged
merged 9 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ skip_list:
- name[template] # Allow Jinja templating inside task and play names
exclude_paths:
- molecule/
- roles/helper_module/
1 change: 1 addition & 0 deletions .github/workflows/enteprise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ jobs:
- name: pki
- name: elasticsearch
- name: identity
- name: prerun_network_checks
runner:
- ubuntu-latest
include:
Expand Down
3 changes: 3 additions & 0 deletions molecule/prerun_network_checks/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: Run the playbook
ansible.builtin.import_playbook: ../../playbooks/prerun-network-checks.yml
5 changes: 5 additions & 0 deletions molecule/prerun_network_checks/host_vars/instance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ansible_user: ansible
# BEGIN KNOWN_URLS VAR
known_urls:
- https://localhost/share/
# END KNOWN_URLS VAR
gionn marked this conversation as resolved.
Show resolved Hide resolved
46 changes: 46 additions & 0 deletions molecule/prerun_network_checks/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
dependency:
name: galaxy
driver:
name: docker
platforms:
- name: instance
image: $MOLECULE_ROLE_IMAGE
dockerfile: ../../tests/molecule/Dockerfile-noprivs.j2
command: "/lib/systemd/systemd"
privileged: true
tmpfs:
- /run
- /run/lock
- /tmp
volume_mounts:
- "/sys/fs/cgroup:/sys/fs/cgroup:ro"
groups:
- database
- activemq
- transformers
- search
- repository
- trusted_resource_consumers
- syncservice
- acc
- adw
- nginx

provisioner:
name: ansible
config_options:
defaults:
pipelining: true
ansible_args:
- -e
- "@../../tests/test-ssl.yml"
inventory:
links:
group_vars: ../../group_vars
host_vars: host_vars
playbooks:
prepare: ../default/prepare.yml
verify: ../default/verify.yml
verifier:
name: ansible
127 changes: 69 additions & 58 deletions playbooks/prerun-network-checks.yml
Original file line number Diff line number Diff line change
@@ -1,188 +1,199 @@
---
# This playbook is used to run preliminary network checks for the hosts in the ACS deployment.
# the default('localhost') is only useful while testing on molecule
- name: Run preliminary network checks for repository hosts
hosts: repository
become: true
roles:
- role: '../roles/helper_modules'
tasks:
- name: Include common defaults
ansible.builtin.include_vars: ../roles/common/defaults/main.yml

- name: Check db connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.database | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.database[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.database[0]].ansible_host | default('localhost') }}"
gionn marked this conversation as resolved.
Show resolved Hide resolved
checked_port: "{{ ports_cfg.postgres.sql }}"
delegate_target: "{{ groups.database | first }}"
when: repo_db_url == ""
when: repo_db_url == "" and groups.database | default([]) | length > 0

- name: Check activemq connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.activemq | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.activemq[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.activemq[0]].ansible_host | default('localhost') }}"
gionn marked this conversation as resolved.
Show resolved Hide resolved
checked_port: "{{ ports_cfg.activemq[activemq_protocol] }}"
delegate_target: "{{ groups.activemq | first }}"
when: groups.activemq | default([]) | length > 0

- name: Check search connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.search | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.search[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.search[0]].ansible_host | default('localhost') }}"
gionn marked this conversation as resolved.
Show resolved Hide resolved
checked_port: "{{ ports_cfg.search.http }}"
delegate_target: "{{ groups.search | first }}"
when: groups.search | default([]) | length > 0

- name: Check sync connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.syncservice | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.syncservice[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
gionn marked this conversation as resolved.
Show resolved Hide resolved
checked_host: "{{ hostvars[groups.syncservice[0]].ansible_host | default('localhost') }}"
checked_port: "{{ ports_cfg.sync.http }}"
delegate_target: "{{ groups.syncservice | first }}"
when:
- groups.syncservice | default([]) | length > 0
- acs.edition == "Enterprise"
alxgomz marked this conversation as resolved.
Show resolved Hide resolved

- name: Check sfs connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.transformers | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.transformers[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.transformers[0]].ansible_host | default('localhost') }}"
gionn marked this conversation as resolved.
Show resolved Hide resolved
checked_port: "{{ ports_cfg.sfs.http }}"
delegate_target: "{{ groups.transformers | first }}"
when: acs.edition == "Enterprise"
when: acs.edition == "Enterprise" and groups.transformers | default([]) | length > 0

- name: Check trouter connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.transformers | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.transformers[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.transformers[0]].ansible_host | default('localhost') }}"
gionn marked this conversation as resolved.
Show resolved Hide resolved
checked_port: "{{ ports_cfg.transformers.trouter }}"
delegate_target: "{{ groups.transformers | first }}"
when: acs.edition == "Enterprise"
when: acs.edition == "Enterprise" and groups.transformers | default([]) | length > 0

- name: Check tengine connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.transformers | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.transformers[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.transformers[0]].ansible_host | default('localhost') }}"
gionn marked this conversation as resolved.
Show resolved Hide resolved
checked_port: "{{ ports_cfg.transformers.tengine }}"
delegate_target: "{{ groups.transformers | first }}"
when: groups.transformers | default([]) | length > 0

- name: Run preliminary network checks for search hosts
hosts: search
become: true
roles:
- role: '../roles/helper_modules'
tasks:
- name: Include common defaults
ansible.builtin.include_vars: ../roles/common/defaults/main.yml

- name: Check repo connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.repository | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.repository[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.repository[0]].ansible_host | default('localhost') }}"
checked_port: "{{ ports_cfg.repository.http }}"
delegate_target: "{{ groups.repository | first }}"
when: groups.repository | default([]) | length > 0

- name: Run preliminary network checks for transformers hosts
hosts: transformers
become: true
roles:
- role: '../roles/helper_modules'
tasks:
- name: Include common defaults
ansible.builtin.include_vars: ../roles/common/defaults/main.yml

- name: Check activemq connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.activemq | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.activemq[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.activemq[0]].ansible_host | default('localhost') }}"
checked_port: "{{ ports_cfg.activemq[activemq_protocol] }}"
delegate_target: "{{ groups.activemq | first }}"
when: groups.activemq | default([]) | length > 0

- name: Run preliminary network checks for syncservice hosts
hosts: syncservice
become: true
roles:
- role: '../roles/helper_modules'
tasks:
- name: Include common defaults
ansible.builtin.include_vars: ../roles/common/defaults/main.yml

- name: Check db connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.database | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.database[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.database[0]].ansible_host | default('localhost') }}"
checked_port: "{{ ports_cfg.postgres.sql }}"
delegate_target: "{{ groups.database | first }}"
when: repo_db_url == ""
when: repo_db_url == "" and groups.database | default([]) | length > 0

- name: Check repo connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.repository | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.repository[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.repository[0]].ansible_host | default('localhost') }}"
checked_port: "{{ ports_cfg.repository.http }}"
delegate_target: "{{ groups.repository | first }}"
when: groups.repository | default([]) | length > 0

- name: Check activemq connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.activemq | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.activemq[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.activemq[0]].ansible_host | default('localhost') }}"
checked_port: "{{ ports_cfg.activemq[activemq_protocol] }}"
delegate_target: "{{ groups.activemq | first }}"
when: groups.activemq | default([]) | length > 0

- name: Run preliminary network checks for acc hosts
hosts: acc
become: true
roles:
- role: '../roles/helper_modules'
tasks:
- name: Include common defaults
ansible.builtin.include_vars: ../roles/common/defaults/main.yml

- name: Check repo connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.repository | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.repository[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.repository[0]].ansible_host | default('localhost') }}"
checked_port: "{{ ports_cfg.repository.http }}"
delegate_target: "{{ groups.repository | first }}"
when: groups.repository | default([]) | length > 0

- name: Run preliminary network checks for adw hosts
hosts: adw
become: true
roles:
- role: '../roles/helper_modules'
tasks:
- name: Include common defaults
ansible.builtin.include_vars: ../roles/common/defaults/main.yml

- name: Check repo connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.repository | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.repository[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.repository[0]].ansible_host | default('localhost') }}"
checked_port: "{{ ports_cfg.repository.http }}"
delegate_target: "{{ groups.repository | first }}"
when: groups.repository | default([]) | length > 0

- name: Run preliminary network checks for nginx hosts
hosts: nginx
become: true
roles:
- role: '../roles/helper_modules'
tasks:
- name: Include common defaults
ansible.builtin.include_vars: ../roles/common/defaults/main.yml

- name: Check repo connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.repository | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.repository[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.repository[0]].ansible_host | default('localhost') }}"
checked_port: "{{ ports_cfg.repository.http }}"
delegate_target: "{{ groups.repository | first }}"
when: groups.repository | default([]) | length > 0

- name: Check sync connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.syncservice | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.syncservice[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.syncservice[0]].ansible_host | default('localhost') }}"
checked_port: "{{ ports_cfg.sync.http }}"
delegate_target: "{{ groups.syncservice | first }}"
when:
- groups.syncservice | default([]) | length > 0
- acs.edition == "Enterprise"

- name: Check acc connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.acc | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.acc[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.acc[0]].ansible_host | default('localhost') }}"
checked_port: "{{ ports_cfg.acc.http }}"
delegate_target: "{{ groups.acc | first }}"
when:
- groups.acc | default([]) | length > 0
- acs.edition == "Enterprise"

- name: Check adw connection
ansible.builtin.include_tasks: "../roles/helper_modules/tasks/check_port.yml"
ansible.builtin.include_tasks: "tasks/check_port.yml"
vars:
checked_host: "{% if groups.adw | length == 0 %}127.0.0.1{% else %}{{ hostvars[groups.adw[0]].ansible_host | default('127.0.0.1') }}{% endif %}"
checked_host: "{{ hostvars[groups.adw[0]].ansible_host | default('localhost') }}"
checked_port: "{{ ports_cfg.adw.http }}"
delegate_target: "{{ groups.adw | first }}"
when:
- groups.adw | default([]) | length > 0
- acs.edition == "Enterprise"
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
- name: Include common defaults
ansible.builtin.include_vars: ../../common/defaults/main.yml

- name: Check connectivity
block:
- name: Check connectivity

Check failure on line 1 in playbooks/tasks/check_port.yml

View workflow job for this annotation

GitHub Actions / pre-commit

key-order[task]

You can improve the task key order to: name, tags, block
block:
# This task needs to be retried in case a previous iteration still listens (default retry of 3 is fine as it aligns with async 10 of listen tasks)
- name: Check if {{ checked_port }} already open on {{ delegate_target }}
register: r_connect
Expand All @@ -21,11 +18,13 @@
delegate_to: "{{ delegate_target }}"
async: 10
poll: 0
- name: Verify if {{ inventory_hostname }} can reach {{ delegate_target }}:{{ checked_port }}
- name: Verify if {{ delegate_target }} is reachable to {{ checked_host }}:{{ checked_port }}
ansible.builtin.wait_for:
host: "{{ checked_host }}"
port: "{{ checked_port }}"
state: started
delay: 0
timeout: 5
msg: Port {{ checked_port }} on the {{ delegate_target }}/{{ checked_host }} machine cannot be reached, please check your firewall!
tags:
- molecule-idempotence-notest
Loading