I first used “package” and ansible complained of a missing interpreter line. 
That’s why I switched to “command”.

I’m going between two CentIS boxes. 

All this doesn’t explain why I can get into the box over ssh, but ansible cant 
get into the box. 

Mike

> On Aug 19, 2019, at 09:02, Jonathan Lozada De La Matta <[email protected]> 
> wrote:
> 
> Mike,
> 
> You should use the yum/apt modules instead of shell/command do what you are 
> trying to do. Also what version of ansible are you using? You should also use 
> the OS conditionals to run the tasks depending on the OS. 
> https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html#commonly-used-facts
>  https://docs.ansible.com/ansible/latest/modules/yum_module.html 
> https://docs.ansible.com/ansible/latest/modules/apt_module.html. you can also 
> use https://docs.ansible.com/ansible/latest/modules/package_module.html for 
> generic package management. If you are using at least ansible 2.7 use the 
> reboot https://docs.ansible.com/ansible/latest/modules/reboot_module.html 
> since it auto connects back.
> 
>> On Mon, Aug 19, 2019 at 9:54 AM Mike Eggleston <[email protected]> wrote:
>> (Doing this on my phone is cumbersome.) :)
>> 
>> Hers the playbook:
>> 
>> [meggle1@dvlnx108 playbooks]$ cat yum.yml
>> # $Id$
>> # $Log$
>>  
>> # use the package manager (yum/apt-get) to update all installed packages
>> # :!ansible-playbook -u root -k --limit dvlnx115 --syntax-check %
>> # :!ansible-playbook -u root -k --limit dvlnx115 %
>> # :!ansible-playbook -vvv -u root -k --limit dvlnx115 %
>> ---
>> - hosts: all
>>   gather_facts: yes
>>  
>>   tasks:
>>     - name: checking for yum...
>>       stat:
>>         path: /usr/bin/yum
>>       register: stat_results
>>       ignore_errors: true
>>  
>>     - name: update all packages (yum)
>>       command: yum -y update
>>       become: yes
>>       notify:
>>         - restart server
>>       when: stat_results.stat.exists
>>  
>>     - name: update all packages (apt-get)
>>       shell: apt-get -y update; apt-get -y upgrade
>>       become: yes
>>       notify:
>>         - restart server
>>       when: not stat_results.stat.exists
>>  
>>  handlers:
>>     - name: restart server
>>       command: shutdown -r now
>>       become: yes
>> 
>> Mike
>> 
>>> On Aug 19, 2019, at 08:40, Jonathan Lozada De La Matta 
>>> <[email protected]> wrote:
>>> 
>>> Mike,
>>> 
>>> If you are provisioning a VM, usually you require another play to connect 
>>> to the host. Can you share the playbook/role?
>>> 
>>>> On Mon, Aug 19, 2019 at 9:38 AM Mike Eggleston <[email protected]> 
>>>> wrote:
>>>> What’s happening here? I can reach the server over ssh, but ansible can’t? 
>>>> I’m testing a provisioning play. I can ssh into the box with “ssh 
>>>> root@box” but the command “ansible-playbook -vvv -u root -k —limit box 
>>>> yum.yml” says “msg”: “SSH Error:data could not be sent to remote host 
>>>> \”box\”. Make sure this host can be reached over ssh”.
>>>> 
>>>> Odd. :)
>>>> 
>>>> What’s happening and how to fix this?
>>>> 
>>>> Mike
>>>> 
>>>> -- 
>>>> 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/7A600E52-96DA-455C-9715-A1D62953C6CD%40gmail.com.
>>> 
>>> 
>>> -- 
>>> Jonathan Cha'gara Lozada De La Matta
>>> He / Him / His
>>> Red Hat
>>> Senior Automation Practice Consultant & Automation CoP Manager
>>> Join the Automation CoP! https://red.ht/autocop
>>> @redhatjobs            redhatjobs  @redhatjobs           
>>>  
>>>  
>>> 
>>> -- 
>>> 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/CAFYJA%2BJBx9_0VWDDJBNn-Y%2BdAMt3eusmm_2g3aMR4o29M%3DovXw%40mail.gmail.com.
>> 
>> -- 
>> 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/337D8801-899B-4B46-9D33-3DD22376E20A%40gmail.com.
> 
> 
> -- 
> Jonathan Cha'gara Lozada De La Matta
> He / Him / His
> Red Hat
> Senior Automation Practice Consultant & Automation CoP Manager
> Join the Automation CoP! https://red.ht/autocop
> @redhatjobs            redhatjobs  @redhatjobs           
>  
>  
> 
> -- 
> 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/CAFYJA%2BL-KTtti4TwCd%3DHkRfhODCm4ya%3DtzNe%3D%2B40kChdORpVUg%40mail.gmail.com.

-- 
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/00D17659-8D62-4DC5-9ED3-94D3F1E61B00%40gmail.com.

Reply via email to