Skip to content

Commit

Permalink
ansible config and log changes
Browse files Browse the repository at this point in the history
Signed-off-by: abhishek-sa1 <[email protected]>
  • Loading branch information
abhishek-sa1 committed Jul 15, 2022
1 parent 4d72723 commit 8208752
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 131 deletions.
13 changes: 13 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[defaults]
log_path = /var/log/omnia.log
host_key_checking = false
forks = 5
timeout = 180

[persistent_connection]
command_timeout = 180
connect_timeout = 180

[ssh_connection]
retries = 3
ssh_args = -o ControlMaster=auto -o ControlPersist=180
13 changes: 13 additions & 0 deletions control_plane/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[defaults]
log_path = /var/log/omnia_control_plane.log
host_key_checking = false
forks = 5
timeout = 180

[persistent_connection]
command_timeout = 180
connect_timeout = 180

[ssh_connection]
retries = 3
ssh_args = -o ControlMaster=auto -o ControlPersist=180
24 changes: 15 additions & 9 deletions control_plane/input_params/base_vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ powervault_support: false

# This variable is used to enable security features on control plane
# Accepted values: "true" or "false"
# Default value: "true"
# If security features are not needed, set this to "false"
enable_security_support: true
# Default value: "false"
# If security features are required, set this to "true"
enable_security_support: false

# The nic/ethernet card that will be connected to the public internet.
# Default value: eno2
Expand Down Expand Up @@ -216,18 +216,24 @@ mgmt_mapping_file_path: ""
roce_network_nic: ""

# The dhcp range for assigning the IPv4 address
# Example: 172.17.0.1
# Example:
# roce_network_dhcp_start_range: "172.21.0.100"
# roce_network_dhcp_end_range: "172.21.0.200"
# Optional
roce_network_dhcp_start_range: ""
roce_network_dhcp_end_range: ""

### Usage: control_plane_ib ###

# The nic/ethernet card that needs to be connected to configure infiniband switch
# This nic will be configured by Omnia for the DHCP server.
# Default value: ib0
ib_network_nic: "ib0"
# Optional
ib_network_nic: ""

# The dhcp range for assigning the IPv4 address
# Example: 172.17.0.1
ib_network_dhcp_start_range: "172.25.0.100"
ib_network_dhcp_end_range: "172.25.0.200"
# Example:
# ib_network_dhcp_start_range: "172.23.0.100"
# ib_network_dhcp_end_range: "172.23.0.200"
# Optional
ib_network_dhcp_start_range: ""
ib_network_dhcp_end_range: ""
70 changes: 10 additions & 60 deletions control_plane/roles/control_plane_common/tasks/pre_requisite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,69 +66,19 @@
mode: "{{ vault_file_perm }}"
tags: init

- name: Check whether ansible config file exists
stat:
path: "{{ ansible_conf_file_path }}/ansible.cfg"
register: ansible_conf_exists
tags: init

- name: Create the directory if it does not exist
file:
path: "{{ ansible_conf_file_path }}"
state: directory
mode: "{{ file_perm }}"
when: not ansible_conf_exists.stat.exists
tags: init

- name: Create ansible config file if it does not exist
- name: Copy ansible.cfg to other folders
copy:
dest: '{{ ansible_conf_file_path }}/ansible.cfg'
mode: "{{ file_perm }}"
content: |
[defaults]
log_path = /var/log/omnia/omnia.log
host_key_checking = false
when: not ansible_conf_exists.stat.exists
tags: init

- name: Check the content of ansible.cfg
command: cat {{ ansible_conf_file_path }}/ansible.cfg
changed_when: false
register: ansible_conf_output
when: ansible_conf_exists.stat.exists
tags: init

- name: Set log_path to omnia.log in ansible.cfg
replace:
path: "{{ ansible_conf_file_path }}/ansible.cfg"
regexp: '#log_path = /var/log/ansible.log'
replace: 'log_path = /var/log/omnia/omnia.log'
when:
- ansible_conf_exists.stat.exists
- '"log_path" in ansible_conf_output.stdout'
tags: init
src: "{{ src_ansible_cfg }}"
dest: "{{ item.path }}"
mode: "{{ vault_file_perm }}"
with_items: "{{ dest_ansible_cfg }}"

- name: Set host_key_checking to false in ansible.cfg
- name: Update log_path in ansible.cfg
replace:
path: "{{ ansible_conf_file_path }}/ansible.cfg"
regexp: '^(.*)host_key_checking(.*)'
replace: 'host_key_checking = false'
when:
- ansible_conf_exists.stat.exists
- '"host_key_checking" in ansible_conf_output.stdout'
tags: init

- name: Set host_key_checking to false in ansible.cfg
lineinfile:
path: "{{ ansible_conf_file_path }}/ansible.cfg"
regexp: "{{ item.check }}"
insertafter: "{{ item.insertafter }}"
line: '{{ item.line }}'
when:
- ansible_conf_exists.stat.exists
- item.check not in ansible_conf_output.stdout
with_items: "{{ ansible_config_details }}"
tags: init
path: "{{ item.path }}"
regexp: "{{ item.regexp }}"
replace: "{{ item.log_path }}"
with_items: "{{ dest_ansible_cfg }}"

- name: Check OS support
assert:
Expand Down
10 changes: 6 additions & 4 deletions control_plane/roles/control_plane_common/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,12 @@ default_ansible_config_file_path: /etc/ansible/ansible.cfg
invalid_run_tag_msg: "Failed. init tag should be used with run tags"
invalid_skip_tag_msg: "Failed. init tag can't be used with skip tags"
omnia_log_path: /var/log/omnia
ansible_config_details:
- { line: "[defaults]", regexp: "^(.*)[defaults](.*)" , check: "[defaults]", insertafter: "BOF" }
- { line: "log_path = /var/log/omnia/omnia.log", regexp: "^(.*)log_path(.*)" , check: "log_path", insertafter: "^(.*)defaults(.*)" }
- { line: "host_key_checking = false", regexp: "^(.*)host_key_checking(.*)" , check: "host_key_checking", insertafter: "^(.*)defaults(.*)" }
src_ansible_cfg: "{{ playbook_dir }}/ansible.cfg"
dest_ansible_cfg:
- { path: "{{ playbook_dir }}/tools/ansible.cfg", log_path: "/var/log/omnia/omnia_control_plane_tools.log", regexp: "/var/log/omnia_control_plane.log" }
- { path: "{{ playbook_dir }}/../telemetry/ansible.cfg", log_path: "/var/log/omnia/omnia_telemetry.log", regexp: "/var/log/omnia_control_plane.log" }
- { path: "{{ playbook_dir }}/../tools/ansible.cfg", log_path: "/var/log/omnia/omnia_tools.log", regexp: "/var/log/omnia_control_plane.log" }
- { path: "{{ playbook_dir }}/../platforms/ansible.cfg", log_path: "/var/log/omnia/omnia_platforms.log", regexp: "/var/log/omnia_control_plane.log" }

# Usage: verify_login_inputs.yml
login_vars_filename: "input_params/login_vars.yml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"type": "loki",
"uid": "control-plane-loki"
},
"expr": "{filename=\"/var/log/omnia/omnia.log\",job=\"Omnia\"}",
"expr": "{filename=\"/var/log/omnia.log\",job=\"Omnia logs\"}",
"queryType": "randomWalk",
"refId": "A"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ scrape_configs:
job: secure
__path__: /var/log/secure

- job_name: Omnia
- job_name: Omnia logs
static_configs:
- targets:
- localhost
labels:
job: Omnia
__path__: /var/log/omnia/omnia.log
job: Omnia logs
__path__: /var/log/omnia.log

- job_name: syslog
static_configs:
Expand Down Expand Up @@ -208,3 +208,43 @@ scrape_configs:
labels:
job: Startup Omnia logs
__path__: /var/log/omnia/startup_omnia/*log

- job_name: Omnia control plane logs
static_configs:
- targets:
- localhost
labels:
job: Omnia control plane logs
__path__: /var/log/omnia_control_plane.log

- job_name: Omnia control plane tools logs
static_configs:
- targets:
- localhost
labels:
job: Omnia control plane tools logs
__path__: /var/log/omnia/omnia_control_plane_tools.log

- job_name: Omnia platforms logs
static_configs:
- targets:
- localhost
labels:
job: Omnia platforms logs
__path__: /var/log/omnia/omnia_platforms.log

- job_name: Omnia tools logs
static_configs:
- targets:
- localhost
labels:
job: Omnia tools logs
__path__: /var/log/omnia/omnia_tools.log

- job_name: Omnia telemetry logs
static_configs:
- targets:
- localhost
labels:
job: Omnia telemetry logs
__path__: /var/log/omnia/omnia_telemetry.log
65 changes: 14 additions & 51 deletions roles/cluster_validation/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,67 +78,30 @@
- powervault_support
- nfs_node_status

- name: Install Packages
include_tasks: install_packages.yml
when: ( not control_plane_status ) or ( not awx_web_support )

- name: omnia.yml runing on host
block:
- name: Passwordless SSH status
debug:
msg: "omnia.yml running on host"
- block:
- name: Install Packages
include_tasks: install_packages.yml

- name: Create log folder for omnia
file:
path: "{{ omnia_log_path }}"
state: directory
mode: "{{ vault_file_perm }}"

- name: Check whether ansible config file exists
stat:
path: "{{ ansible_conf_file_path }}/ansible.cfg"
register: ansible_conf_exists

- name: Create the directory if it does not exist
file:
path: "{{ ansible_conf_file_path }}"
state: directory
mode: "{{ file_perm }}"
when: not ansible_conf_exists.stat.exists

- name: Create ansible config file if it does not exist
- name: Copy ansible.cfg to other folders
copy:
dest: "{{ ansible_conf_file_path }}/ansible.cfg"
mode: "{{ file_perm }}"
content: |
[defaults]
log_path = /var/log/omnia/omnia.log
when: not ansible_conf_exists.stat.exists

- name: Check the content of ansible.cfg
command: cat {{ ansible_conf_file_path }}/ansible.cfg
changed_when: false
register: ansible_conf_output
when: ansible_conf_exists.stat.exists
src: "{{ ansible_cfg_src }}"
dest: "{{ item.path }}"
mode: "{{ vault_file_perm }}"
with_items: "{{ ansible_cfg_dest }}"

- name: Set omnia.log file
- name: Update log_path in ansible.cfg
replace:
path: "{{ ansible_conf_file_path }}/ansible.cfg"
regexp: '#log_path = /var/log/ansible.log'
replace: 'log_path = /var/log/omnia/omnia.log'
when: ansible_conf_exists.stat.exists

- name: Set host_key_checking to false in ansible.cfg
lineinfile:
path: "{{ ansible_conf_file_path }}/ansible.cfg"
regexp: "{{ item.check }}"
insertafter: "{{ item.insertafter }}"
line: '{{ item.line }}'
when:
- ansible_conf_exists.stat.exists
- item.check not in ansible_conf_output.stdout
with_items: "{{ ansible_config_details }}"
path: "{{ item.path }}"
regexp: "{{ item.regexp }}"
replace: "{{ item.log_path }}"
with_items: "{{ ansible_cfg_dest }}"
when: ( not control_plane_status ) or ( not awx_web_support )

- name: Include gather_facts playbook
include_tasks: gather_fact_resolution.yml
9 changes: 6 additions & 3 deletions roles/cluster_validation/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
awx_search_key: "-job-"
base_vars_path: "{{ playbook_dir }}/control_plane/input_params/base_vars.yml"
cobbler_pod_name: cobbler
ansible_config_details:
- { line: "[defaults]", regexp: "^(.*)[defaults](.*)" , check: "[defaults]", insertafter: "BOF" }
- { line: "log_path = /var/log/omnia/omnia.log", regexp: "^(.*)log_path(.*)" , check: "log_path", insertafter: "^(.*)defaults(.*)" }
omnia_log_path: /var/log/omnia
cp_path: "/root/.ansible/cp/"
ansible_cfg_src: "{{ playbook_dir }}/ansible.cfg"
ansible_cfg_dest:
- { path: "{{ playbook_dir }}/control_plane/tools/ansible.cfg", log_path: "/var/log/omnia/omnia_control_plane_tools.log", regexp: "/var/log/omnia.log" }
- { path: "{{ playbook_dir }}/telemetry/ansible.cfg", log_path: "/var/log/omnia/omnia_telemetry.log", regexp: "/var/log/omnia.log" }
- { path: "{{ playbook_dir }}/tools/ansible.cfg", log_path: "/var/log/omnia/omnia_tools.log", regexp: "/var/log/omnia.log" }
- { path: "{{ playbook_dir }}/platforms/ansible.cfg", log_path: "/var/log/omnia/omnia_platforms.log", regexp: "/var/log/omnia.log" }

# Usage: fetch_omnia_inputs.yml
config_filename: "omnia_config.yml"
Expand Down

0 comments on commit 8208752

Please sign in to comment.