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: yes

  vars:
    python_exec: /cygdrive/c/Python27/python.exe
    working_dir: /cygdrive/c/abc/run/ab

    sharefile_script: /cygdrive/c/abc/run/ab/tests/sharefile_api_test.py
    confl_script: /cygdrive/c/abc/run/ab/tests/confluence_api_test.py

  tasks:
    - name: Place test script
      win_template:
        src: templates/sharefiles_confluence.template
        dest: ~/sharefiles_confluence.sh
        owner: "{{ admin }}"
        mode: u+rwx,g+rwx
      ignore_errors: yes

    - name: Do a test run of Sharefiles and Confluence API scripts...
      raw: ~/sharefiles_confluence.sh
      ignore_errors: yes
      register: result
    - debug: 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/bash

export 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:

[agenerette@buildplaybooks]$ ansible-playbook -e admin=agenerette -e 
targets=wrk04 -e @~/.ansible/secure.yml sharefiles_confluence.yml 
--ask-vault-pass
...

PLAY [wrk04] *********************************************************

TASK [Place test script] 
*******************************************************
ok: [wrk04]

TASK [Do a test run of Sharefiles and Confluence API scripts...] 
***************
changed: [wrk04]

TASK [debug] 
*******************************************************************
ok: [wrk04] => {
    "result": {
        "changed": true,
        "rc": 0,
        "stderr": "",
        "stdout": "",
        "stdout_lines": []
    }
}

PLAY RECAP 
*********************************************************************
wrk04            : ok=3    changed=1    unreachable=0    failed=0

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/35a21de6-6b62-4aa6-a1aa-f545e9119b77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to