Skip to content
Snippets Groups Projects
Commit 2f839b23 authored by Gin Tan's avatar Gin Tan
Browse files

Merge branch 'add_nhc_nat_check' into 'master'

check to see if NAT is working by pinging hpc-lic0

See merge request hpc-team/ansible_cluster_in_a_box!202
parents f28af416 c9634c30
No related branches found
No related tags found
1 merge request!202check to see if NAT is working by pinging hpc-lic0
Creates Node Health Check on a compute node
see ://github.com/mej/nhc
It needs some variable to be defined before calling
i.e.
nhc_version: 1.4.2
nhc_dir: /opt/nhc-{{ nhc_version }}
nhc_config_file: nhc.conf
nhc_log_level: 0
nhc_emails: nobody@nowhere.nowhere
nhc_email_subject: "Node Health Check"
In addition the NAT check needs two variables to be defined to be enabled (See example)
- ADD_NHC_NAT_CHECK has to be defined to (any) value
- NHC_NAT_CHK_EXTERNAL_IP_ADDRESS is the address to be pinged
Example:
roles:
- { role: nhc, NHC_NAT_CHK_EXTERNAL_IP_ADDRESS: "118.138.246.208", ADD_NHC_NAT_CHECK: 1 }
...@@ -60,3 +60,14 @@ ...@@ -60,3 +60,14 @@
become: true become: true
become_user: root become_user: root
#test NAT is working by pinging an external address, i.e. a license server, or by default Google Public DNS
- set_fact:
EXTERNAL_IP_ADDRESS: "8.8.8.8"
when: EXTERNAL_IP_ADDRESS is undefined
- name: install nhc NAT check
template: dest="{{ nhc_dir }}/etc/nhc/scripts/check_nat.nhc" src=check_nat.nhc.j2
become: true
become_user: root
when: ADD_NHC_NAT_CHECK is defined
#!/bin/bash
#checks that NAT is working by pinging an external address from a compute node
function check_nat() {
#echo ">>> Checking NAT on Compute Nodes Works >>>>>>>>>>>>>>>>>>>>>>>>>"
#test NAT by pinging an external IP ADDRESS
PING_EXTERNAL="ping -c 2 {{ NHC_NAT_CHK_EXTERNAL_IP_ADDRESS }}"
$PING_EXTERNAL
RESULT=$?
if [ $RESULT -ne 0 ]; then
die 1 " $FUNCNAME ERROR on node. Can not ping external address. Command is ' ${PING_EXTERNAL} ' Please check NAT is working, or route on node is valid"
return 1
fi
return 0
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment