This issue got resolved : issue was related to *connection: local*
for some reason when that was on delegate_to was being ignored [i don't
know if i am saying this right...]
well things working & issues resolved after commenting that out...
On Friday, June 3, 2022 at 1:04:40 PM UTC-4 Ashish Patel wrote:
> Update:
> I able to confirm the issue is in ***delegate_to***
> Even though we see log is printing things getting executed on remote host,
> it's not...
>
> I replaced execute Mongo code with below code & i only saw local host
> files...
>
> * - name: "debug - validate - files in /usr/bin"*
> * shell: "ls -l /usr/bin/m*"*
> * loop: "{{ my_server_list.split(',') }}"*
> * loop_control:*
> * loop_var: server_item*
> * when: (server_item | length > 5)*
> * delegate_to: "{{ server_item }}"*
> * register: work_start*
> * changed_when: false*
>
>
> I did confirm SSH & Sudo works fine between local & remote host
>
>
> On Thursday, June 2, 2022 at 3:11:45 PM UTC-4 Ashish Patel wrote:
>
>> Greetings Experts :)
>>
>> Thank you for looking at this & sparing your precious time to help me
>> with this..
>>
>> My initial portion of Playbook:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *---- hosts: localhost connection: local gather_facts: false vars:
>> # change_number - from awx - [format]: CHG[0-9]+ # serverlist - from
>> awx # mongo_userlst - from awx - [format]: [{'username':
>> {'external_auth': True, 'roles': {'rolename': {'db': 'admin'}, ...}}}] #
>> mongo_rolelst - from awx - [format]: [{'rolename': {'roles': { 'RolePriv1':
>> {'db': 'database1'}, ...}}}] # snow_environment - from awx
>> ds_vault_environment: prod vault_username: "{{ lookup*** }}"
>> vault_password: "{{ lookup*** }}" roles: - mongodb_common -
>> ds_snow_common tasks: - name: "xx- Set TOKEN fact to TOKEN environment
>> variable" set_fact: TOKEN: "{{ lookup*** }}" no_log: "{{
>> hide_sensitive_info | default(True) }}" - name: "xx- Set TOKEN fact when
>> the TOKEN environment variable was not set." include_role:
>> name: sensitive_for_pass when: sensitive_for_pass - name: "xx-
>> lookup relevant passwords for play" set_fact: upassword: "{{
>> lookup*** }}" snow_password: "{{ lookup*** }}" - name: "xx-
>> validate User Definition following Standard" include_role:
>> name: mongodb_roles_users tasks_from: validate_definition.yml
>> loop: "{{ mongo_userlst }}" loop_control: loop_var:
>> mongodb_user_role when: (mongo_userlst|default([]) | length > 0) -
>> name: "xx- validate User Role Definition following Standard"
>> include_role: name: mongodb_roles_users tasks_from:
>> validate_definition.yml loop: "{{ mongo_rolelst }}"
>> loop_control: loop_var: mongodb_user_role when:
>> (mongo_rolelst|default([]) | length > 0) - name: "xx- set required facts
>> for future plays and tasks" set_fact: username: "{{
>> mongo_admin_account }}" my_user_list: "{{ mongo_userlst }}"
>> my_role_list: "{{ mongo_rolelst }}" my_server_list: "{{ serverlist |
>> replace(' ', '') }}" auth_string: " --username {{
>> mongo_admin_account }} --authenticationMechanism='PLAIN'
>> --authenticationDatabase='admin' -p '{{ upassword }}' admin" - name:
>> "xx- get all prim servers" shell: /usr/bin/mongo --port {{ pport }}
>> --host {{ server_item }} {{ auth_string }} -quiet --eval "{{ shell_command
>> }}" vars: shell_command: "rs.isMaster().primary" pport:
>> 123 loop: "{{ my_server_list.split(',') }}" loop_control:
>> loop_var: server_item when: (server_item | length > 5)
>> delegate_to: "{{ server_item }}" register: prim_server_list
>> changed_when: false*
>> *...*
>> *...*
>> *...*
>> FYI, *I tried a shell module with proper single quotes &
>> double quotes as well, but got the same error.. *
>>
>>
>> *Error I received:*
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *TASK [xx- get all prim servers] ******************************task path:
>> /tmp/bwrap_1424_dasvtmvy/awx_1424_93abt0t9/project/playbooks/mongodb_gen_account.yml:66<servername.domain>
>>
>> ESTABLISH LOCAL CONNECTION FOR USER: root<servername.domain> EXEC /bin/sh
>> -c 'echo ~root && sleep 0'<servername.domain> EXEC /bin/sh -c '( umask 77
>> && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir "` echo
>> /root/.ansible/tmp/ansible-tmp-1654194046.0317488-72-17477654263645 `" &&
>> echo ansible-tmp-1654194046.0317488-72-17477654263645="` echo
>> /root/.ansible/tmp/ansible-tmp-1654194046.0317488-72-17477654263645 `" ) &&
>> sleep 0'<localhost> Attempting python interpreter
>> discovery<servername.domain> EXEC /bin/sh -c 'echo PLATFORM; uname; echo
>> FOUND; command -v '"'"'/usr/bin/python'"'"'; command -v
>> '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v
>> '"'"'python3.5'"'"'; command -v '"'"'python2.7'"'"'; command -v
>> '"'"'python2.6'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"';
>> command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'python'"'"'; echo
>> ENDFOUND && sleep 0'<servername.domain> EXEC /bin/sh -c '/usr/bin/python3.6
>> && sleep 0'Using module file
>> /opt/payx-custom-venvs/base/lib/python3.6/site-packages/ansible/modules/command.py<servername.domain>
>>
>> PUT /var/lib/awx/.ansible/tmp/ansible-local-21lnly3nd/tmp73xe7ln0 TO
>> /root/.ansible/tmp/ansible-tmp-1654194046.0317488-72-17477654263645/AnsiballZ_command.py<servername.domain>
>>
>> EXEC /bin/sh -c 'chmod u+x
>> /root/.ansible/tmp/ansible-tmp-1654194046.0317488-72-17477654263645/
>> /root/.ansible/tmp/ansible-tmp-1654194046.0317488-72-17477654263645/AnsiballZ_command.py
>>
>> && sleep 0'<servername.domain> EXEC /bin/sh -c
>> '/usr/libexec/platform-python
>> /root/.ansible/tmp/ansible-tmp-1654194046.0317488-72-17477654263645/AnsiballZ_command.py
>>
>> && sleep 0'<servername.domain> EXEC /bin/sh -c 'rm -f -r
>> /root/.ansible/tmp/ansible-tmp-1654194046.0317488-72-17477654263645/ >
>> /dev/null 2>&1 && sleep 0'failed: [localhost -> servername.domain]
>> (item=servername.domain) => { "ansible_loop_var": "server_item",
>> "changed": false, "cmd": "/usr/bin/mongo --port 123 --host
>> servername.domain --username username --authenticationMechanism='PLAIN'
>> --authenticationDatabase='admin' -p 'password' admin -quiet --eval
>> \\"rs.isMaster().primary\\"", "delta": "0:00:00.003849", "end":
>> "2022-06-02 18:20:46.495075", "invocation": { "module_args": {
>> "_raw_params": "/usr/bin/mongo --port 123 --host servername.domain
>> --username username --authenticationMechanism='PLAIN'
>> --authenticationDatabase='admin' -p 'password' admin -quiet --eval
>> \\"rs.isMaster().primary\\"", "_uses_shell": true,
>> "argv": null, "chdir": null, "creates": null,
>> "executable": null, "removes": null, "stdin":
>> null, "stdin_add_newline": true, "strip_empty_ends":
>> true, "warn": true } }, "msg": "non-zero return
>> code", "rc": 127, "server_item": "servername.domain", "start":
>> "2022-06-02 18:20:46.491226", "stderr": "/bin/sh: /usr/bin/mongo: No
>> such file or directory", "stderr_lines": [ "/bin/sh:
>> /usr/bin/mongo: No such file or directory" ], "stdout": "",
>> "stdout_lines": []}PLAY RECAP
>> *********************************************************************localhost
>>
>> : ok=14 changed=0 unreachable=0 failed=1
>> skipped=6 rescued=0 ignored=0 *
>>
>>
>>
>>
>> I assure that the file exists & has proper permission so the user can
>> execute on the server..
>>
>>
>>
>> *0602_145552 me@myVDI playbook ]: ssh servername ls -l
>> /usr/bin/mongo-rwxr-xr-x. 1 root root 59291368 Sep 19 2021
>> /usr/bin/mongo0602_145614 me@myVDI playbook ]:*
>>
>>
>>
>> Thank you for your time,
>> Best,
>> Ashish
>>
>
--
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/2be0f42d-bb80-4fec-ae07-e3f1415afbaan%40googlegroups.com.