Hi All.
I have a list of hosts that I am trying to check connectivity and ensure
that ansible tower can connect to it with the defined credential, so we are
checking 2 things here.
Connectivity to ensure that the host is online.
Ensure that ansible can connect with the defined credentials.
The issue I am having now is that the fact gatherng process does get stuck,
to get around this issue I specified the gather_timeout of 30 seconds, this
has not made any effect. If the timeout is completely removed, there is no
effect also. The issue is that the failure to gather facts leads to a
complete halt/stop of the playbook, what i ideally want is that if the
gthering of facts fails for a host, break out and move on to the next host.
The error is as follows.
fatal: [servername]: UNREACHABLE ! => {"changed": false, msg": "ntlm:
HTTPConnectionPool(host='servername',port=5985) Max retries exceeded with
url: /wsman (Caused by
NewConnectionError('<urllib3.connection.HTTPConnection object at
0x75c590cb9a50<: Failed to establish a new connection: [Errorno -2] Name of
service not known',))", "unreachable":true}
My playbook is as follows.
---
- name: Include Host
add_host:
name: "{{item}}"
with_items: "{{} jump_server }}"
- name: Central Controller
hosts: all
gather_facts: no
serial: 1
tasks:
- name: Setup credentials
include_role:
name: roles/creds/connect_credentials
no_log: true
- name: Gather facts
setup:
async: 0
poll: 0
register: returned_facts
- include_role:
name: log_results
*connect_credentials *
---
- name: Set Credentials
set_fact:
ansible_user: domain\username
ansible_password: xxxxxx
ansible_become: true
ansible_become_method: runas
ansible_become_user: domain\username
ansible_become_password: xxxxxx
ansible_become_flags: login_type=new_credentials
logon_flags=netcredentials_only
ansible_connection: winrm
ansiblansible_winrm_scheme: http
ansible_winrm_transport: ntlm
ansible_port: 5985
ansible_winrm_Server_cert_validation: ignore
ansible_winrm_kerberos_delegation: true
ansible_winrm_operation_timeout_sec: 30
ansible_winrm_read_timeout_sec: 60
*log_Results role*
---
- block:
- name: Call API to log succcessful connection
include_role:
name: api_logger
vars:
servername: "{{inventory_hostname}}"
ignore_errors: false
when: returned_facts.unreachable is undefined
- name: Deal with failed gather facts
setup:
ignore_unreablable: yes
delegate_to: localhost
delegate_facts: true
register: localhost_time
- name: debug
set_fact:
current_time:
"{{localhost_time.ansible_facts.ansible_date_time.iso8601}}"
when: returned_facts.unreachable is defined
- name: Call API to log succcessful connection
include_role:
name: api_logger
vars:
servername: "{{inventory_hostname}}"
ignore_errors: false
when: returned_facts.unreachable is defined
rescue:
- debug:
msg: "Error"
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/0e983856-709f-49fa-ad26-733ebbdfe5d3n%40googlegroups.com.