|
@@ -17,28 +17,76 @@
|
|
|
command: cat {{ input_config_filename }}
|
|
|
changed_when: false
|
|
|
register: config_content
|
|
|
-
|
|
|
-- name: Decrpyt input_config.yml
|
|
|
- command: ansible-vault decrypt {{ input_config_filename }} --vault-password-file {{ role_path }}/files/{{ vault_filename }}
|
|
|
+S
|
|
|
+- name: Decrpyt appliance_config.yml
|
|
|
+ command: >-
|
|
|
+ ansible-vault decrypt {{ input_config_filename }}
|
|
|
+ --vault-password-file {{ vault_filename }}
|
|
|
changed_when: false
|
|
|
when: "'$ANSIBLE_VAULT;' in config_content.stdout"
|
|
|
|
|
|
-- name: Include variable file input_config.yml
|
|
|
+- name: Include variable file appliance_config.yml
|
|
|
include_vars: "{{ input_config_filename }}"
|
|
|
+ no_log: true
|
|
|
|
|
|
- name: Validate input parameters are not empty
|
|
|
fail:
|
|
|
msg: "{{ input_config_failure_msg }}"
|
|
|
register: input_config_check
|
|
|
- when: (provision_password | length < 1) or (awx_password | length < 1) or (mariadb_password | length < 1) or (hpc_nic | length < 1) or (public_nic | length < 1)
|
|
|
+ when:
|
|
|
+ - provision_password | length < 1 or
|
|
|
+ awx_password | length < 1 or
|
|
|
+ hpc_nic | length < 1 or
|
|
|
+ public_nic | length < 1 or
|
|
|
+ dhcp_start_ip_range | length < 1 or
|
|
|
+ dhcp_end_ip_range | length < 1
|
|
|
|
|
|
- name: Save input variables from file
|
|
|
set_fact:
|
|
|
cobbler_password: "{{ provision_password }}"
|
|
|
admin_password: "{{ awx_password }}"
|
|
|
- input_mariadb_password: "{{ mariadb_password }}"
|
|
|
nic: "{{ hpc_nic }}"
|
|
|
internet_nic: "{{ public_nic }}"
|
|
|
+ dhcp_start_ip: "{{ dhcp_start_ip_range | ipv4 }}"
|
|
|
+ dhcp_end_ip: "{{ dhcp_end_ip_range | ipv4 }}"
|
|
|
+ mapping_file: "{{ mapping_file_exists }}"
|
|
|
+ no_log: true
|
|
|
+
|
|
|
+- name: Get the system hpc ip
|
|
|
+ shell: "ifconfig {{ hpc_nic }} | grep 'inet' |cut -d: -f2 | awk '{ print $2}'"
|
|
|
+ register: ip
|
|
|
+ changed_when: false
|
|
|
+
|
|
|
+- name: Get the system public ip
|
|
|
+ shell: "ifconfig {{ internet_nic }} | grep 'inet' |cut -d: -f2 | awk '{ print $2}'"
|
|
|
+ register: internet_ip
|
|
|
+ changed_when: false
|
|
|
+
|
|
|
+- name: Get the system netmask
|
|
|
+ shell: "ifconfig {{ hpc_nic }} | grep 'inet' |cut -d: -f2 | awk '{ print $4}'"
|
|
|
+ register: net
|
|
|
+ changed_when: false
|
|
|
+
|
|
|
+- name: HPC nic IP
|
|
|
+ set_fact:
|
|
|
+ hpc_ip: "{{ ip.stdout }}"
|
|
|
+ public_ip: "{{ internet_ip.stdout }}"
|
|
|
+
|
|
|
+- name: Netmask
|
|
|
+ set_fact:
|
|
|
+ netmask: "{{ net.stdout }}"
|
|
|
+
|
|
|
+- name: shell try
|
|
|
+ shell: |
|
|
|
+ IFS=. read -r i1 i2 i3 i4 <<< "{{ hpc_ip }}"
|
|
|
+ IFS=. read -r m1 m2 m3 m4 <<< "{{ netmask }}"
|
|
|
+ printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
|
|
|
+ register: sub_result
|
|
|
+ changed_when: false
|
|
|
+
|
|
|
+- name: Subnet
|
|
|
+ set_fact:
|
|
|
+ subnet: "{{ sub_result.stdout }}"
|
|
|
|
|
|
- name: Assert provision_password
|
|
|
assert:
|
|
@@ -51,6 +99,7 @@
|
|
|
- " \"'\" not in cobbler_password "
|
|
|
success_msg: "{{ success_msg_provision_password }}"
|
|
|
fail_msg: "{{ fail_msg_provision_password }}"
|
|
|
+ no_log: true
|
|
|
register: cobbler_password_check
|
|
|
|
|
|
- name: Assert awx_password
|
|
@@ -64,20 +113,24 @@
|
|
|
- " \"'\" not in admin_password "
|
|
|
success_msg: "{{ success_msg_awx_password }}"
|
|
|
fail_msg: "{{ fail_msg_awx_password }}"
|
|
|
+ no_log: true
|
|
|
register: awx_password_check
|
|
|
|
|
|
-- name: Assert mariadb_password
|
|
|
+- name: Assert hpc_ip
|
|
|
+ assert:
|
|
|
+ that:
|
|
|
+ - hpc_ip | length > 7
|
|
|
+ success_msg: "{{ success_hpc_ip }}"
|
|
|
+ fail_msg: "{{ fail_hpc_ip }}"
|
|
|
+ register: hpc_ip_check
|
|
|
+
|
|
|
+- name: Assert public_ip
|
|
|
assert:
|
|
|
that:
|
|
|
- - input_mariadb_password | length > min_length | int - 1
|
|
|
- - input_mariadb_password | length < max_length | int + 1
|
|
|
- - '"-" not in input_mariadb_password '
|
|
|
- - '"\\" not in input_mariadb_password '
|
|
|
- - '"\"" not in input_mariadb_password '
|
|
|
- - " \"'\" not in input_mariadb_password "
|
|
|
- success_msg: "{{ success_msg_mariadb_password }}"
|
|
|
- fail_msg: "{{ fail_msg_mariadb_password }}"
|
|
|
- register: mariadb_password_check
|
|
|
+ - public_ip | length > 7
|
|
|
+ success_msg: "{{ success_hpc_ip }}"
|
|
|
+ fail_msg: "{{ fail_hpc_ip }}"
|
|
|
+ register: public_ip_check
|
|
|
|
|
|
- name: Assert hpc_nic
|
|
|
assert:
|
|
@@ -93,11 +146,70 @@
|
|
|
that:
|
|
|
- internet_nic | length > nic_min_length | int - 1
|
|
|
- nic != internet_nic
|
|
|
- - "('em1' in internet_nic) or ('em2' in internet_nic) or ('em3' in internet_nic)"
|
|
|
success_msg: "{{ success_msg_public_nic }}"
|
|
|
fail_msg: "{{ fail_msg_public_nic }}"
|
|
|
register: public_nic_check
|
|
|
|
|
|
+- name: Assert mapping_file_exists
|
|
|
+ assert:
|
|
|
+ that:
|
|
|
+ - "( mapping_file == true) or ( mapping_file == false)"
|
|
|
+ success_msg: "{{ success_mapping_file }}"
|
|
|
+ fail_msg: "{{ fail_mapping_file }}"
|
|
|
+ register: mapping_file_check
|
|
|
+
|
|
|
+- name: Check the subnet of dhcp start range
|
|
|
+ shell: |
|
|
|
+ IFS=. read -r i1 i2 i3 i4 <<< "{{ dhcp_start_ip }}"
|
|
|
+ IFS=. read -r m1 m2 m3 m4 <<< "{{ netmask }}"
|
|
|
+ printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
|
|
|
+ args:
|
|
|
+ warn: no
|
|
|
+ register: dhcp_start_sub_result
|
|
|
+ changed_when: false
|
|
|
+ when: dhcp_start_ip != "false"
|
|
|
+
|
|
|
+- name: Set the start dhcp subnet
|
|
|
+ set_fact:
|
|
|
+ dhcp_start_sub: "{{ dhcp_start_sub_result.stdout }}"
|
|
|
+ when: dhcp_start_ip != "false"
|
|
|
+
|
|
|
+- name: Check the subnet of dhcp end range
|
|
|
+ shell: |
|
|
|
+ IFS=. read -r i1 i2 i3 i4 <<< "{{ dhcp_end_ip }}"
|
|
|
+ IFS=. read -r m1 m2 m3 m4 <<< "{{ netmask }}"
|
|
|
+ printf "%d.%d.%d.%d\n" "$((i1 & m1))" "$((i2 & m2))" "$((i3 & m3))" "$((i4 & m4))"
|
|
|
+ register: dhcp_end_sub_result
|
|
|
+ when: dhcp_end_ip != "false"
|
|
|
+ changed_when: false
|
|
|
+
|
|
|
+- name: Set the end dhcp subnet
|
|
|
+ set_fact:
|
|
|
+ dhcp_end_sub: "{{ dhcp_end_sub_result.stdout }}"
|
|
|
+ when: dhcp_end_ip != "false"
|
|
|
+
|
|
|
+- name: Assert dhcp_start_ip_range
|
|
|
+ assert:
|
|
|
+ that:
|
|
|
+ - dhcp_start_ip != "false"
|
|
|
+ - dhcp_start_ip != dhcp_end_ip
|
|
|
+ - dhcp_start_sub == subnet
|
|
|
+ - dhcp_start_sub == dhcp_end_sub
|
|
|
+ success_msg: "{{ success_dhcp_range }}"
|
|
|
+ fail_msg: "{{ fail_dhcp_range }}"
|
|
|
+ register: dhcp_start_ip_check
|
|
|
+
|
|
|
+- name: Assert dhcp_end_ip_range
|
|
|
+ assert:
|
|
|
+ that:
|
|
|
+ - dhcp_end_ip != "false"
|
|
|
+ - dhcp_start_ip != dhcp_end_ip
|
|
|
+ - dhcp_end_sub == subnet
|
|
|
+ - dhcp_start_sub == dhcp_end_sub
|
|
|
+ success_msg: "{{ success_dhcp_range }}"
|
|
|
+ fail_msg: "{{ fail_dhcp_range }}"
|
|
|
+ register: dhcp_end_ip_check
|
|
|
+
|
|
|
- name: Create ansible vault key
|
|
|
set_fact:
|
|
|
vault_key: "{{ lookup('password', '/dev/null chars=ascii_letters') }}"
|
|
@@ -105,7 +217,7 @@
|
|
|
|
|
|
- name: Save vault key
|
|
|
copy:
|
|
|
- dest: "{{ role_path }}/files/{{ vault_filename }}"
|
|
|
+ dest: "{{ vault_filename }}"
|
|
|
content: |
|
|
|
{{ vault_key }}
|
|
|
owner: root
|
|
@@ -113,5 +225,7 @@
|
|
|
when: "'$ANSIBLE_VAULT;' not in config_content.stdout"
|
|
|
|
|
|
- name: Encrypt input config file
|
|
|
- command: ansible-vault encrypt {{ input_config_filename }} --vault-password-file {{ role_path }}/files/{{ vault_filename }}
|
|
|
- changed_when: false
|
|
|
+ command: >-
|
|
|
+ ansible-vault encrypt {{ input_config_filename }}
|
|
|
+ --vault-password-file {{ vault_filename }}
|
|
|
+ changed_when: false
|