problem with shell module and actual command passed

8 views
Skip to first unread message

lolO lolO

unread,
Apr 2, 2020, 3:35:01 AM4/2/20
to Ansible Project
Hello all !

it's been a while i have troubles with the shell module:
as a command is correctly executed in console (even launched as the user awx)

git push g...@savetogit.skylab.local:savetogit/devbackupdesconfigs.git

but fails through the playbook execution with the output

i've already tried a lot of changes (character protection, command line in variable, local script)
same issue
the output is
ssh: Could not resolve hostname savetogit.skylab.local: Name or service not know

any idea why such a parsing?

---
the aim is to push to a remote git (skylab.local)
as the user 'savetogit'
this works perfectly ion console

thanks

Stefan Hornburg (Racke)

unread,
Apr 2, 2020, 4:29:02 AM4/2/20
to ansible...@googlegroups.com
On 4/2/20 9:35 AM, lolO lolO wrote:
> Hello all !
>
> it's been a while i have troubles with the shell module:
> as a command is correctly executed in console (even launched as the user awx)
>
> /git push g...@savetogit.skylab.local:savetogit/devbackupdesconfigs.git/
>
> but fails through the playbook execution with the output
>
> i've already tried a lot of changes (character protection, command line in variable, local script)
> same issue
> the output is
> ssh: Could not resolve hostname savetogit.skylab.local: Name or service not know
>
> any idea why such a parsing?

How does your playbook / task look like? In the Git URL above you have savetogit.skylab.local,
but below you say you want to push to skylab.local.

Regards
Racke

>
> ---
> the aim is to push to a remote git (skylab.local)
> as the user 'savetogit'
> this works perfectly ion console
>
> thanks
>
> --
> 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
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/b56dcee9-4b31-4c7e-b03c-41c824c3e024%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/b56dcee9-4b31-4c7e-b03c-41c824c3e024%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

signature.asc

lolO lolO

unread,
Apr 2, 2020, 6:08:16 AM4/2/20
to Ansible Project
Hello Racke,

here 's my git tasks:
=====
tasks: 
    - name: git local actions
      shell: | 
        git config --global user.name "save...@babel.local"
        git add -A
        git commit -m "Ajout des nouveaux fichiers au repo"
        exit 0

      args:
        chdir: "{{ workingdir }}"

    - name: git push to remote
      shell: "git push g...@savetogit.skylab.local:savetogit/devbackupdesconfigs.git"
    
      args:
        chdir: "{{ workingdir }}"
    
     
      register: gitcommand_return
      changed_when: gitcommand_return.stdout is not search('nothing to commit')
      failed_when: "'FAILED' in gitcommand_return.stderr"

====

my gitlab server is skylab.local
the syntax git push g...@savetogit.skylab.local:savetogit/devbackupdesconfigs.git allows to push with another ssh user credential (user = savetogit)
it works fine in console

Stefan Hornburg (Racke)

unread,
Apr 2, 2020, 6:21:03 AM4/2/20
to ansible...@googlegroups.com
On 4/2/20 12:08 PM, lolO lolO wrote:
> Hello Racke,
>
> here 's my git tasks:
> =====
> tasks: 
>     - name: git local actions
>       shell: | 
>         git config --global user.name "save...@babel.local"
>         git add -A
>         git commit -m "Ajout des nouveaux fichiers au repo"
>         exit 0
>
>       args:
>         chdir: "{{ workingdir }}"
>
>     - name: git push to remote
>       shell: "git push g...@savetogit.skylab.local:savetogit/devbackupdesconfigs.git"
>     
>       args:
>         chdir: "{{ workingdir }}"
>     
>      
>       register: gitcommand_return
>       changed_when: gitcommand_return.stdout is not search('nothing to commit')
>       failed_when: "'FAILED' in gitcommand_return.stderr"
>
> ====
>
> my gitlab server is skylab.local
> the syntax *git push g...@savetogit.skylab.local:savetogit/devbackupdesconfigs.git *allows to push with another ssh user
> credential (user = savetogit)
> it works fine in console
>

I think the correct push command for the remote user savetogit would be:

git push save...@skylab.local:savetogit/devbackupdesconfigs.git

Regards
Racke

>
>
>
>
> Le jeudi 2 avril 2020 09:35:01 UTC+2, lolO lolO a écrit :
>
> Hello all !
>
> it's been a while i have troubles with the shell module:
> as a command is correctly executed in console (even launched as the user awx)
>
> /git push g...@savetogit.skylab.local:savetogit/devbackupdesconfigs.git/
>
> but fails through the playbook execution with the output
>
> i've already tried a lot of changes (character protection, command line in variable, local script)
> same issue
> the output is
> ssh: Could not resolve hostname savetogit.skylab.local: Name or service not know
>
> any idea why such a parsing?
>
> ---
> the aim is to push to a remote git (skylab.local)
> as the user 'savetogit'
> this works perfectly ion console
>
> thanks
>
> --
> 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
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/0fc9cc86-18b4-457e-880f-296d255c4eb0%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/0fc9cc86-18b4-457e-880f-296d255c4eb0%40googlegroups.com?utm_medium=email&utm_source=footer>.
signature.asc

lolO lolO

unread,
Apr 2, 2020, 8:05:26 AM4/2/20
to Ansible Project
in console :

-bash-4.2$ whoami
awx
-bash-4.2$ git push g...@savetogit.skylab.local:savetogit/devbackupdesconfigs.git
Counting objects: 9, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 503 bytes | 0 bytes/s, done.
Total 5 (delta 1), reused 0 (delta 0)
To g...@savetogit.skylab.local:savetogit/devbackupdesconfigs.git
   bcbe3ed..2cfbb27  master -> master


-bash-4.2$ git push save...@skylab.local:savetogit/devbackupdesconfigs.git
save...@skylab.local's password:

this second command doesn't work with ssh keys and asks password

--
my problem is within ansible shell command execution, all is fine in simple shell


Le jeudi 2 avril 2020 09:35:01 UTC+2, lolO lolO a écrit :
Reply all
Reply to author
Forward
0 new messages