I have a CentOS7 control server from which I am trying to manage a few Server2012/Cygwin nodes. Those latter nodes have Cygwin setup such that its sshd component is installed and running (I’m able to successfully ssh to the targets).
My ~/.ansible.cfg is the active one and this file contains
inventory = ~/playbooks/inv/hosts
The relevant entries in that inventory file for target that I’ve focused on are (note: the “abc_*” variables referenced in the inventory file are stored in a vault file that’s pulled in, of course, at run time):
[abc_windows]
wrk04 ansible_host=< target’s IP >[abc_windows:vars]
ansible_user = “{{ abc_win_ansible_user }}”
ansible_password = “{{ abc_win_ansible_pwd }}”
ansible_port = 5986
ansible_winrm_transport = ntlm
ansible_connection = winrm
ansible_winrm_server_cert_validation = ignore
A GUI based installer for my company’s software drops in a bunch of files that include the ones referenced in the python_exec, working_dir, sharefile_script, and confl_script variables, below.
Now, among other things, I’ve been trying to automate the task of running a couple of Python scripts against each of the managed nodes. The playbook, template, and shell script, pasted below, seek to accomplish that end. At the very end of this posting, you can see the output that I get, when I run the playbook. The “/tmp/sharefiles_confl.log” file is never created and the scripts never get run, as far as I can tell.
[agenerette@build playbooks]$ cat sharefiles_confluence.yml
- hosts: “{{ targets }}”
user: “{{ admin }}”
gather_facts: yesvars:
python_exec: /cygdrive/c/Python27/python.exe
working_dir: /cygdrive/c/abc/run/absharefile_script: /cygdrive/c/abc/run/ab/tests/sharefile_api_test.py
confl_script: /cygdrive/c/abc/run/ab/tests/confluence_api_test.pytasks:
name: Place test script
win_template:
src: templates/sharefiles_confluence.template
dest: ~/sharefiles_confluence.sh
owner: “{{ admin }}”
mode: u+rwx,g+rwx
ignore_errors: yesname: Do a test run of Sharefiles and Confluence API scripts…
raw: ~/sharefiles_confluence.sh
ignore_errors: yes
register: resultdebug: var=result
NOTE: the “my_*” variables referenced in the following template are also stored in the vault file that’s pulled in, of course, at run time:
[agenerette@build playbooks]$ cat templates/sharefiles_confluence.template
#!/bin/bashexport ldap_user=“{{ my_ldap_user }}”
export ldap_pass=“{{ my_ldap_pass }}”
export ldap_reg_code=“null”
export gdoc_pass=“{{ my_gdoc_pass }}”
export share_user=“{{ my_sharefiles_user }}”
export share_pass=“{{ my_sharefiles_pass }}”
export wiki_user=“{{ my_ldap_user }}”
export wiki_pass=“{{ my_ldap_pass }}”echo $ldap_user > /tmp/sharefiles_confl.log
“{{ python_exec }} {{ sharefile_script }} && {{ python_exec }} {{ confl_script }}” >> /tmp/sharefiles_confl.log
And here’s a sample run, with output: