'playbook runs with ansible-playbook successfully but does nothing in ansible tower

I have ansible installed on the Windows Subsystem for Linux. This version is 2.9.6.

I also have an ansible tower that is version 3.7.2 which has Ansible version 2.9.27.

I basically use the ansible installation on my WSL to play with and debug playbooks to get them working. Once they are working, I upload them to my Git Repository and pull them into the Ansible Tower for execution.

I am still fairly new to Ansible so perhaps this is a very simple issue. I have a playbook that runs just fine on my ansible (2.9.6) WLS environment.

When I run the same playbook in my Ansible Tower, it doesn't run any tasks.

The playbook is fairly simple. I want to use it to change the password on a local Windows account. The playbook is in a file named change_user_password.yml. The contents are shown below:

- name: Change user password
  hosts: all
  tasks:
  - name: Include OS-specific variables.
    include_vars: "{{ ansible_os_family }}.yml"

  - name: Print OS Family
    debug:
      msg: "Ansible OS family is {{ ansible_os_family }}"

  - name: Print uname
    debug:
      msg: "Uname variable is {{ uname }}"

  - name: Print newpass
    debug:
      msg: "Newpass variable is {{ newpass }}"

  - name: Change pwd (Redhat).
    ping:
    when: ansible_os_family == 'RedHat'

  - name: Change pwd (Debian).
    ping:
    when: ansible_os_family == 'Debian'

  - name: Change pwd (Windows).
    win_user:
      name: "{{ uname }}"
      password: "{{ newpass }}"
    when: ansible_os_family == 'Windows'

When run on the command line with ansible-playbook in my WSL environment I pass in the --extra-vars for uname and newpass variables as shown below:

ansible-playbook -i ../hosts.ini --limit cssvr-prod change_user_password.yml --extra-vars="uname=myadmin newpass=test1234TEST"

Output typically looks like this:

PLAY [Change user password] ***************************************************************************************************************************************************************************

TASK [Gathering Facts] ********************************************************************************************************************************************************************************
ok: [cssvr-prod]

TASK [Include OS-specific variables.] *****************************************************************************************************************************************************************
ok: [cssvr-prod]

TASK [Print OS Family] ********************************************************************************************************************************************************************************
ok: [cssvr-prod] => {
    "msg": "Ansible OS family is Windows"
}

TASK [Print uname] ************************************************************************************************************************************************************************************
ok: [cssvr-prod] => {
    "msg": "Uname variable is myadmin"
}

TASK [Print newpass] **********************************************************************************************************************************************************************************
ok: [cssvr-prod] => {
    "msg": "Newpass variable is test1234TEST"
}

TASK [Change pwd (Redhat).] ***************************************************************************************************************************************************************************
skipping: [cssvr-prod]

TASK [Change pwd (Debian).] ***************************************************************************************************************************************************************************
skipping: [cssvr-prod]

TASK [Change pwd (Windows).] **************************************************************************************************************************************************************************
changed: [cssvr-prod]

PLAY RECAP ********************************************************************************************************************************************************************************************
cssvr-prod                 : ok=6    changed=1    unreachable=0    failed=0    skipped=2    rescued=0    ignored=0



When I run this playbook from Ansible Tower, I add uname and newpass as extra variables in the Extra Variables box on the Template for this play.  I add the cssvr-prod host in the Limit box. When I run it, no tasks are run.  NOTE: The warning below is expected, the inventory and groups are imported from Azure.  Some of our Azure resource groups have hyphens in their name which apparently is illegal in the ansible hosts file as a group name.

Using /etc/ansible/ansible.cfg as config file
SSH password: 
[WARNING]: Invalid characters were found in group names but not replaced, use
-vvvv to see details
PLAY [all] *********************************************************************
PLAY RECAP *********************************************************************

I'm pulling what little hair I have left out trying to figure out why the code behaves this way on Tower.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source