(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.

Reply via email to