Ansible - Error "MODULE FAILURE" on Windows hosts - ansible

I'm trying to use Ansible but I have a problem with some Windows hosts. When I start my playbook, I have the following message on this hosts but I don't understand why.
Error Message :
fatal: [XXXXXXX.DOMAIN.COM]: FAILED! => {"ansible_facts": {}, "changed": false,
"failed_modules": {"ansible.legacy.setup": {"failed": true, "module_stderr": "",
"module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}},
"msg": "The following modules failed to execute: ansible.legacy.setup\n"}
Variables ansible :
ansible_user: admin#DOMAIN.COM
ansible_password: Password
ansible_connection: winrm
ansible_winrm_transport: kerberos
ansible_winrm_server_cert_validation: ignore
ansible_winrm_port: 5986
I checked if my config WINRM was good. My listener HTTPS is configured and I have the rule WINRM HTTPS for port 5986 activate

Related

adhoc ansible command not coming

172.31.52.50 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Warning: Permanently added '172.31.52.50' (ECDSA) to the list of known hosts.\r\nroot#172.31.52.50: Permission denied (publickey,password).",
"unreachable": true
}
172.31.56.245 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Host key verification failed.",
"unreachable": true
}
Can you anyone solve the issues
Given the hosts file:
[deveopshint]
172.31.52.50
172.31.56.245
I cant connect the slaves or managed nodes

Ansible - #CLIXML error on a windows host

I have an issue when I run my playbook.yaml with -vvvv during Gathering Facts. I have the following error message :
fatal: [HOST.DOMAIN.COM]: FAILED! => {
"ansible_facts": {},
"changed": false,
"failed_modules": {
"ansible.legacy.setup": {
"failed": true,
"module_stderr": "#< CLIXML\r\n",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
},
"msg": "The following modules failed to execute: ansible.legacy.setup\n"
I search on internet and I try different things like change the size of max memory per shell but it changes nothing.
Do you know how to resolve it or a way that i can explore for solve it pls ? If I need to change my config ?
Playbook.yaml :
- name: Who am I
hosts: win
tasks:
- name: Check my user name
ansible.windows.win_whoami:
win.yaml (variables) :
ansible_user: admin#DOMAIN.COM
ansible_password: Password
ansible_connection: winrm
ansible_winrm_transport: kerberos
ansible_winrm_server_cert_validation: ignore
ansible_winrm_port: 5986
My Windows host :
OS : Microsoft Windows Server 2016 Standard
Powershell Version : 5.1.14393.5127

Ansible DellOS6 Config Backup

EDIT: After some research, I wonder if this may be related to the on_become() function as described in this post? https://github.com/Dell-Networking/ansible-dellos-examples/issues/12
I am trying to backup our current configurations on our Dell 2048p switches, running OS6. No matter what I set the timeout to (using persistent_connection in ansible.cfg), it still errors out. I have checked the logs on the switch and it gets both the show ver and show running-config commands, however its just not making it back. I have looked at the Networking and Troubleshooting guide, but am having trouble getting a proper error. Does anyone have this working, or spot anything I can change?
Version
ansible 2.9.5
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/me/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.6/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0]
Playbook
-
name: Show ver
hosts: Dell
connection: network_cli
gather_facts: yes
tasks:
-
name: "Get Dell EMC OS6 Show version"
dellos6_command:
commands: ['show version']
register: show_ver
-
name: "Backup config file locally"
dellos6_config:
backup: yes
backup_options:
dir_path: "/mnt/c/Users/me/Documents/Programming Projects/netBackupPlaybooks"
filename: "{{ inventory_hostname }}"
authorize: yes
register: backup_dellso6_location
when: ansible_network_os == 'dellos6'
- debug: var=show_ver
- debug: var=backup_dellos6_location
Inventory
[Dell]
sw1 ansible_host=10.10.10.10 ansible_ssh_extra_args='-o StrictHostKeyChecking=no' ansible_ssh_common_args='-o StrictHostKeyChecking=no' ansible_network_os=dellos6 ansible_connection=network_cli ansible_become_method=enable ansible_become_password=admin ansible_user=admin ansible_password=admin
sw2 ansible_host=10.10.10.11 ansible_ssh_extra_args='-o StrictHostKeyChecking=no' ansible_ssh_common_args='-o StrictHostKeyChecking=no' ansible_network_os=dellos6 ansible_connection=network_cli ansible_become_method=enable ansible_become_password=admin ansible_user=admin ansible_password=admin
Command
sudo ansible-playbook -i inventory.ini DellPB.yaml -vvvv
Error
The full traceback is:
WARNING: The below traceback may *not* be related to the actual failure.
File "/tmp/ansible_dellos6_config_payload_pjEND4/ansible_dellos6_config_payload.zip/ansible/module_utils/network/dellos6/dellos6.py", line 86, in get_config
return _DEVICE_CONFIGS[cmd]
fatal: [sw2]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"after": null,
"auth_pass": null,
"authorize": true,
"backup": true,
"backup_options": null,
"before": null,
"config": null,
"host": null,
"lines": null,
"match": "line",
"parents": null,
"password": null,
"port": null,
"provider": null,
"replace": "line",
"save": false,
"src": null,
"ssh_keyfile": null,
"timeout": null,
"update": "merge",
"username": null
}
},
"msg": "unable to retrieve current config",
"stderr": "command timeout triggered, timeout value is 30 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide.",
"stderr_lines": [
"command timeout triggered, timeout value is 30 secs.",
"See the timeout setting options in the Network Debug and Troubleshooting Guide."
]
Just wanted to edit for anyone else experiencing this issue. It looks like it was a bug in the module that will be fixed in the latest release of Ansible.
https://github.com/ansible/ansible/pull/63272

Handlers not getting invoked after a task

I am trying to automate some tasks using Ansible. In my playbooks, I have a copy task and then i change the permissions of the file. I need the service to restart after this task. I am including notify and have also declared my handler, but strangely this handler is never getting invoked.
Excerpt from my playbook
- name: Configure Audit Log Purge Scheduler
copy:
src: "Scheduler-Log-Purge.config"
dest: "{{ crx_dir }}install/com.adobe.cq.audit.purge.Scheduler-LogPurge.config"
become: true
tags: aem
- name: Change Permissions of the Log Purge Scheduler config File
file:
path: "{{ crx_dir }}install/com.adobe.cq.audit.purge.Scheduler-LogPurge.config"
owner: crx
group: crx
become: true
notify: restart aem
tags: aem
- name: Pause the execution for cq5 to come up
pause:
minutes: 5
tags: aem
And here is my handler file contents.
---
- name: restart aem
service: name=cq5 state=restarted
become: yes
The o/p after running the playbook
gparasha-macOS:TLTD gparasha$ ansible-playbook -i hosts tltd.yml --tags aem -v
No config file found; using defaults
PLAY [Run tasks on Author] **************************************************************************************************************************************************************
TASK [Gathering Facts] ******************************************************************************************************************************************************************
ok: [35.169.196.183]
PLAY [Run AEM Specific Steps on Author] *************************************************************************************************************************************************
TASK [Gathering Facts] ******************************************************************************************************************************************************************
ok: [35.169.196.183]
TASK [publish : Configure Audit Log Purge Scheduler] ************************************************************************************************************************************
ok: [35.169.196.183] => {"changed": false, "checksum": "3a9d00ea8357fd217a9442b1c408065abf077dfc", "failed": false, "gid": 1005, "group": "crx", "mode": "0644", "owner": "crx", "path": "/mnt/crx/author/crx-quickstart/install/com.adobe.cq.audit.purge.Scheduler-LogPurge.config", "secontext": "user_u:object_r:usr_t:s0", "size": 277, "state": "file", "uid": 1005}
TASK [publish : Change Permissions of the Log Purge Scheduler config File] **************************************************************************************************************
ok: [35.169.196.183] => {"changed": false, "failed": false, "gid": 1005, "group": "crx", "mode": "0644", "owner": "crx", "path": "/mnt/crx/author/crx-quickstart/install/com.adobe.cq.audit.purge.Scheduler-LogPurge.config", "secontext": "user_u:object_r:usr_t:s0", "size": 277, "state": "file", "uid": 1005}
TASK [publish : Pause the execution for cq5 to come up] *********************************************************************************************************************************
Pausing for 300 seconds
(ctrl+C then 'C' = continue early, ctrl+C then 'A' = abort)
Press 'C' to continue the play or 'A' to abort
fatal: [35.169.196.183]: FAILED! => {"failed": true, "msg": "user requested abort!"}
But when i run this playbook, the restart of this service is not invoked.
Why is this so?
Can we not use notify in file modules?
Any help will be deeply appreciated.
You can attach notify to any module.
But Ansible will notify handler only when task is in changed state – this is on purpose to prevent unnecessary handlers execution (e.g. service restarts) on subsequent playbook runs.
Your log excerpts show "changed": false for the task in question, so handler execution is not triggered.
Also keep in mind that handlers are executed at the very end of the role/playbook unless they are explicitly flushed with meta, so in your scenario handler will be executed after Pause the execution for cq5 to come up task.

Not able to ping windows machine using Ansible

I am new to Ansible and trying to connect to windows machine using Ansible.
I am getting following error
xxx.xxx.xxx.com | UNREACHABLE! => {
"changed": false,
"msg": "plaintext: HTTPConnectionPool(host='xxx.xxx.xxx.com', port=5985): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x3d76050>: Failed to establish a new connection: [Errno 111] Connection refused',))",
"unreachable": true
}
I have made changes in these three files.
Inventory:
[windows]
xxx.xxx.xxx.com
Krb5.conf
[realms]
XXX.XXX.COM = {
kdc = xxx.xxx.xxx.com
admin_server = xxx.xxx.xxx.com
}
[domain_realm]
.xxx.xxx.com = XXX.XXX.COM
group_vars/windows.yml
ansible_ssh_user: user
ansible_ssh_pass: password
ansible_ssh_port: 5985
ansible_connection: winrm
I am new to this and may have made mistake in the process of connectivity.
Any help would be appreciated. Thanks in advance.
The msg key says "plaintext", you need to enable winrm over ssl on the windows hosts with this PowerShell script provided by ansible:
https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1
Since that will add a self signed certificate be sure to add ansible_winrm_server_cert_validation: ignore to your group_vars/windows.yml

Resources