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

Fix ansible lint #310

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 6 additions & 3 deletions deploy_cluster.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
---
- import_playbook: playbooks/validate_inventory.yml
- name: Validate Inventory
ansible.builtin.import_playbook: playbooks/validate_inventory.yml

- import_playbook: playbooks/deploy_cluster_agent_based_installer.yml
- name: Deploy cluster using agent based installer
ansible.builtin.import_playbook: playbooks/deploy_cluster_agent_based_installer.yml
when: (use_agent_based_installer | default(true)) | bool

- import_playbook: playbooks/deploy_cluster_assisted_installer.yml
- name: Deploy cluster using agent based installer
ansible.builtin.import_playbook: playbooks/deploy_cluster_assisted_installer.yml
when: not ((use_agent_based_installer | default(true)) | bool)
21 changes: 14 additions & 7 deletions deploy_day2_workers.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
- import_playbook: playbooks/validate_inventory.yml
- name: Validate inventory
ansible.builtin.import_playbook: playbooks/validate_inventory.yml

- import_playbook: playbooks/create_vms.yml
- name: Create VMs
import_playbook: playbooks/create_vms.yml
when: groups['day2_workers'] | default([]) | length > 0
vars:
nodes_to_process: "{{ groups['day2_workers'] | default([]) }}"
Expand All @@ -11,21 +13,26 @@
# are trying to join
DELETE_VM_BRIDGE: false

- import_playbook: playbooks/create_day2_cluster.yml
- name: Create Day 2 cluster instance
ansible.builtin.import_playbook: playbooks/create_day2_cluster.yml

- import_playbook: playbooks/generate_discovery_iso.yml
- name: Generate Day 2 discovery iso
ansible.builtin.import_playbook: playbooks/generate_discovery_iso.yml
when: groups['day2_workers'] | default([]) | length > 0
vars:
discovery_iso_name: "{{ day2_discovery_iso_name }}"
iso_cluster_id: "{{ add_host_cluster_id }}"

- import_playbook: playbooks/boot_iso.yml
- name: Boot Day 2 ISO
import_playbook: playbooks/boot_iso.yml
when: groups['day2_workers'] | default([]) | length > 0
vars:
discovery_iso_name: "{{ day2_discovery_iso_name }}"
boot_iso_url: "{{ discovery_iso_server }}/{{ day2_discovery_iso_name }}"
boot_iso_hosts: day2_workers

- import_playbook: playbooks/add_day2_nodes.yml
- name: Add day 2 nodes to cluster
ansible.builtin.import_playbook: playbooks/add_day2_nodes.yml

- import_playbook: playbooks/approve_csrs.yml
- name: Approve node CSRs
ansible.builtin.import_playbook: playbooks/approve_csrs.yml
27 changes: 18 additions & 9 deletions deploy_prerequisites.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
---
- import_playbook: prereq_facts_check.yml
- name: Prereq fact checks
ansible.builtin.import_playbook: prereq_facts_check.yml

- name: Play to populate image_hashes for relevant images
hosts: localhost
roles:
- redhatci.ocp.get_image_hash

- import_playbook: playbooks/deploy_ntp.yml
- name: Deploy NTP
ansible.builtin.import_playbook: playbooks/deploy_ntp.yml

- import_playbook: playbooks/deploy_http_store.yml
- name: Deploy HTTP Store
ansible.builtin.import_playbook: playbooks/deploy_http_store.yml

- import_playbook: playbooks/create_vms.yml
- name: Create VMs
ansible.builtin.import_playbook: playbooks/create_vms.yml
vars:
nodes_to_process: "{{ groups['masters'] + groups['workers'] | default([]) }}"

- import_playbook: playbooks/deploy_tftp.yml
- name: Deploy TFTP
ansible.builtin.import_playbook: playbooks/deploy_tftp.yml

- import_playbook: playbooks/deploy_dns.yml
- name: Deploy DNS
ansible.builtin.import_playbook: playbooks/deploy_dns.yml

- import_playbook: playbooks/deploy_registry.yml
- name: Deploy Registry
ansible.builtin.import_playbook: playbooks/deploy_registry.yml

- import_playbook: playbooks/deploy_assisted_installer_onprem.yml
- name: Deploy assisted installer on prem
ansible.builtin.import_playbook: playbooks/deploy_assisted_installer_onprem.yml
when: not ((use_agent_based_installer | default(true)) | bool)

- import_playbook: playbooks/deploy_sushy_tools.yml
- name: Deploy Sushy Tools
ansible.builtin.import_playbook: playbooks/deploy_sushy_tools.yml
6 changes: 3 additions & 3 deletions playbooks/deploy_registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
- name: Setup facts
ansible.builtin.setup:
when: SETUP_REGISTRY_SERVICE | bool
- name: pre-compute need to get hashes
- name: Pre-compute need to get hashes
ansible.builtin.set_fact:
run_get_hash: "{{ image_hashes | default({}) | length == 0 }}"
run_get_hash: "{{ image_hashes | default({}) | length == 0 }}"
roles:
- role: redhatci.ocp.get_image_hash
when: run_get_hash

- name: Play to install and setup mirror registry
hosts: registry_host
gather_facts: False
gather_facts: false
vars:
downloads_path: /tmp/wip
config_file_path: /tmp/wip/config
Expand Down
8 changes: 6 additions & 2 deletions playbooks/populate_registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- name: Play to populate image_hashes for relevant images
hosts: localhost
gather_facts: (setup_registry_service | default(true)) | bool
gather_facts: false
vars:
destination_hosts:
- registry_host
Expand All @@ -19,10 +19,14 @@

- name: Play populate mirror registry
hosts: registry_host
gather_facts: "{{ (setup_registry_service | default(true)) | bool }}"
gather_facts: false
vars:
config_file_path: /tmp/wip/config
SETUP_REGISTRY_SERVICE: "{{ setup_registry_service | default(true)}}"
pre_tasks:
- name: Setup facts
ansible.builtin.setup:
when: SETUP_REGISTRY_SERVICE | bool
roles:
- role: redhatci.ocp.populate_mirror_registry
when: SETUP_REGISTRY_SERVICE | bool
6 changes: 3 additions & 3 deletions roles/display_deployment_plan/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Get all PXE Nodes
set_fact:
ansible.builtin.set_fact:
pxe_node_names: "{{ pxe_node_names + [item] }}"
when: hostvars[item]['vendor'] | lower == 'pxe'
loop: "{{ groups['nodes'] }}"
Expand All @@ -9,7 +9,7 @@
when: not ((skip_interactive_prompts | default(false)) | bool)
block:
- name: Display inventory details and ask for user confirmation
pause:
ansible.builtin.pause:
prompt: "{{ lookup('template', 'plan.j2').strip('\n') }}"
vars:
# Every row consists of two columns. To ensure all items in the right column are aligned,
Expand Down Expand Up @@ -65,7 +65,7 @@
register: display_deployment_plan__confirmation

- name: Assert the deployment plan is confirmed
assert:
ansible.builtin.assert:
that:
- (display_deployment_plan__confirmation.user_input | lower | trim) in ['y', 'yes']
fail_msg: "The deployment plan must be confirmed by the user"
Expand Down
1 change: 0 additions & 1 deletion roles/validate_inventory/tasks/ai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
ver_query: "[?version=='{{ openshift_full_version }}']"
block:
- name: Assert os_images exists
vars:
ansible.builtin.assert:
that:
- os_images is defined
Expand Down
2 changes: 1 addition & 1 deletion roles/validate_inventory/tasks/day2.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: Check for day2_discovery_iso_name if required
assert:
ansible.builtin.assert:
that:
- day2_discovery_iso_name is defined
when: (groups['day2_workers'] | default([])) | length > 0
6 changes: 3 additions & 3 deletions roles/validate_inventory/tasks/dns.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- name: Assert 'dhcp_range_first' and 'dhcp_range_last' are defined if needed
assert:
ansible.builtin.assert:
that:
- hostvars['dns_host'][item] is defined
- hostvars['dns_host'][item] | ansible.utils.ipaddr('bool') == True
Expand All @@ -10,8 +10,8 @@
- dhcp_range_first
- dhcp_range_last

- name: if DNS DHCP setup is enabled, ntp_server MUST be an IP for DNS config
assert:
- name: If DNS DHCP setup is enabled, ntp_server MUST be an IP for DNS config
ansible.builtin.assert:
that:
- hostvars['dns_host']['ntp_server'] is defined
- hostvars['dns_host']['ntp_server'] | ansible.utils.ipaddr('bool') == True
Expand Down
52 changes: 33 additions & 19 deletions roles/validate_inventory/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,95 @@
---
- name: Validate Inventory
when: not (inventory_validated | default(False) | bool)
delegate_to: "{{ validation_host | default('bastion') }}"
block:
- include_tasks:
- name: Check required vars
ansible.builtin.include_tasks:
file: required_vars.yml
apply:
tags: validate_required_vars
tags: validate_required_vars

- include_tasks:
- name: Check cluster values
ansible.builtin.include_tasks:
file: cluster.yml
apply:
tags: validate_cluster
tags: validate_cluster

- include_tasks:
- name: Check vendor vars
ansible.builtin.include_tasks:
file: vendor.yml
apply:
tags: validate_vendor
tags: validate_vendor

- include_tasks:
- name: Check ntp vars
ansible.builtin.include_tasks:
file: ntp.yml
apply:
tags: validate_ntp
tags: validate_ntp

- include_tasks:
- name: Check VM vars
ansible.builtin.include_tasks:
file: vms.yml
apply:
tags: validate_vms
tags: validate_vms

- include_tasks:
- name: Check secrets
ansible.builtin.include_tasks:
file: secrets.yml
apply:
tags: validate_secrets
tags: validate_secrets

- include_tasks:
- name: Check prereqs
ansible.builtin.include_tasks:
file: prereqs.yml
apply:
tags: validate_prereqs
tags: validate_prereqs

- include_tasks:
- name: Check proxy vars
ansible.builtin.include_tasks:
file: proxy.yml
apply:
tags: validate_proxy_config
tags: validate_proxy_config

- include_tasks:
- name: Check network vars
ansible.builtin.include_tasks:
file: network.yml
apply:
tags: validate_network
tags: validate_network

- include_tasks:
- name: Check day2 vars
ansible.builtin.include_tasks:
file: day2.yml
apply:
tags: validate_day2
tags: validate_day2

- include_tasks:
- name: Check partitions vars
ansible.builtin.include_tasks:
file: partitions.yml
apply:
tags: validate_partitions
tags: validate_partitions

- include_tasks:
- name: Check pxe vars
ansible.builtin.include_tasks:
file: validate_pxe.yml
apply:
tags: validate_pxe
tags: validate_pxe
when: (setup_pxe_service | default(false)) | bool

- include_tasks:
- name: Check installer feature gates
ansible.builtin.include_tasks:
file: agent_based_installer_feature_gates.yml
apply:
tags: validate_agent_based_installer
Expand All @@ -83,20 +98,19 @@
- not ((ignore_agent_based_installer_feature_gates | default(false)) | bool)
tags: validate_agent_based_installer

- include_tasks:
- name: Check agent based installer requirements
ansible.builtin.include_tasks:
file: agent_based_installer_requirements.yml
apply:
tags: validate_agent_based_installer
when:
- (use_agent_based_installer | default(true) | bool)
tags: validate_agent_based_installer

when: not (inventory_validated | default(False) | bool)
delegate_to: "{{ validation_host | default('bastion') }}"

- name: Record successful validation on all hosts
set_fact:
inventory_validated: True
ansible.builtin.set_fact:
inventory_validated: true
delegate_to: "{{ item }}"
delegate_facts: True
delegate_facts: true
loop: "{{ groups['all'] + ['localhost'] }}"
12 changes: 6 additions & 6 deletions roles/validate_inventory/tasks/network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
# Node `ansible_host`s are not pinged. They are not required to be running at this stage.
# KVM node BMCs are not checked, the vm_host will be pinged later.
- name: Ensure baremetal node BMCs are reachable
shell: # noqa 305
ansible.builtin.shell: # noqa command-instead-of-shell
cmd: "ping -c 1 -W 2 {{ hostvars[item]['bmc_ip'] | default(hostvars[item]['bmc_address']) }}"
changed_when: False
changed_when: false
when: hostvars[item]['vendor'] | lower != 'kvm'
loop: "{{ groups['nodes'] }}"

- name: Ensure service hosts are reachable
shell: # noqa 305
ansible.builtin.shell: # noqa command-instead-of-shell
cmd: "ping -c 1 -W 2 {{ hostvars[item]['ansible_host'] }}"
changed_when: False
changed_when: false
loop: "{{ groups['services'] }}"

- name: Ensure NTP server is available if not being set up
shell: # noqa 305
ansible.builtin.shell: # noqa command-instead-of-shell
cmd: "ping -c 1 -W 2 {{ ntp_server }}"
changed_when: False
changed_when: false
when: (setup_ntp_service | default(True)) != True
2 changes: 1 addition & 1 deletion roles/validate_inventory/tasks/ntp.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: Check ntp_server is valid
assert:
ansible.builtin.assert:
that:
- hostvars['ntp_host']['ntp_server'] is defined
- hostvars['ntp_host']['ntp_server'] | ansible.utils.ipaddr('bool') == True
Expand Down
4 changes: 2 additions & 2 deletions roles/validate_inventory/tasks/partitions.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- name: Assert that partitions can be create on supported Openshift version
assert:
ansible.builtin.assert:
that:
- openshift_full_version is version('4.8', '>=')
- openshift_full_version is version('4.8', '>=')
fail_msg: "openshift_full_version must be >= 4.8."
when: hostvars[item]['disks'] is defined
loop: "{{ groups['nodes'] | default([]) }}"
6 changes: 4 additions & 2 deletions roles/validate_inventory/tasks/prereqs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
- import_tasks: ai.yml
- name: Check installer vars
ansible.builtin.import_tasks: ai.yml

- import_tasks: dns.yml
- name: Check DNS vars
ansible.builtin.import_tasks: dns.yml
Loading
Loading