Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-19 Thread Tony Wong
tony@ubuntu:~/ansiblework$ sudo apt-add-repository ppa:ansible/ansible
 Ansible is a radically simple IT automation platform that makes your
applications and systems easier to deploy. Avoid writing scripts or custom
code to deploy and update your applications— automate in a language that
approaches plain English, using SSH, with no agents to install on remote
systems.

http://ansible.com/
 More info: https://launchpad.net/~ansible/+archive/ubuntu/ansible
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 https://download.docker.com/linux/ubuntu bionic InRelease
Hit:2 http://ppa.launchpad.net/ansible/ansible/ubuntu cosmic InRelease
Ign:3 http://archive.ubuntu.com/ubuntu cosmic InRelease
Ign:4 http://archive.ubuntu.com/ubuntu cosmic-updates InRelease
Ign:5 http://archive.ubuntu.com/ubuntu cosmic-backports InRelease
Ign:6 http://archive.ubuntu.com/ubuntu cosmic-security InRelease
Err:7 http://archive.ubuntu.com/ubuntu cosmic Release
  404  Not Found [IP: 91.189.88.152 80]
Err:8 http://archive.ubuntu.com/ubuntu cosmic-updates Release
  404  Not Found [IP: 91.189.88.152 80]
Err:9 http://archive.ubuntu.com/ubuntu cosmic-backports Release
  404  Not Found [IP: 91.189.88.152 80]
Err:10 http://archive.ubuntu.com/ubuntu cosmic-security Release
  404  Not Found [IP: 91.189.88.152 80]
Reading package lists... Done
E: The repository 'http://archive.ubuntu.com/ubuntu cosmic Release' no
longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore
disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration
details.
E: The repository 'http://archive.ubuntu.com/ubuntu cosmic-updates Release'
no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore
disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration
details.
E: The repository 'http://archive.ubuntu.com/ubuntu cosmic-backports
Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore
disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration
details.
E: The repository 'http://archive.ubuntu.com/ubuntu cosmic-security
Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore
disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration
details.
tony@ubuntu:~/ansiblework$ sudo apt-get update
Hit:1 https://download.docker.com/linux/ubuntu bionic InRelease
Ign:2 http://archive.ubuntu.com/ubuntu cosmic InRelease
Hit:3 http://ppa.launchpad.net/ansible/ansible/ubuntu cosmic InRelease
Ign:4 http://archive.ubuntu.com/ubuntu cosmic-updates InRelease
Ign:5 http://archive.ubuntu.com/ubuntu cosmic-backports InRelease
Ign:6 http://archive.ubuntu.com/ubuntu cosmic-security InRelease
Err:7 http://archive.ubuntu.com/ubuntu cosmic Release
  404  Not Found [IP: 91.189.88.142 80]
Err:8 http://archive.ubuntu.com/ubuntu cosmic-updates Release
  404  Not Found [IP: 91.189.88.142 80]
Err:9 http://archive.ubuntu.com/ubuntu cosmic-backports Release
  404  Not Found [IP: 91.189.88.142 80]
Err:10 http://archive.ubuntu.com/ubuntu cosmic-security Release
  404  Not Found [IP: 91.189.88.142 80]
Reading package lists... Done
E: The repository 'http://archive.ubuntu.com/ubuntu cosmic Release' no
longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore
disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration
details.
E: The repository 'http://archive.ubuntu.com/ubuntu cosmic-updates Release'
no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore
disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration
details.
E: The repository 'http://archive.ubuntu.com/ubuntu cosmic-backports
Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore
disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration
details.
E: The repository 'http://archive.ubuntu.com/ubuntu cosmic-security
Release' no longer has a Release file.
N: Updating from such a repository can't be done securely, and is therefore
disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration
details.

On Sun, Apr 19, 2020 at 2:15 PM David Foley  wrote:

> $ sudo apt update
>>> $ sudo apt install software-properties-common
>>> $ sudo apt-add-repository --yes --update ppa:ansible/ansible
>>> $ sudo apt install ansible
>>>
>>> https://docs.ansible.com/ansible/2.3/intro_installation.html
>
> No you don't need to have the latest Ubuntu 19
>
>>
>>>
>>> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop 

Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-19 Thread David Foley

>
> $ sudo apt update
>> $ sudo apt install software-properties-common
>> $ sudo apt-add-repository --yes --update ppa:ansible/ansible
>> $ sudo apt install ansible
>>
>> https://docs.ansible.com/ansible/2.3/intro_installation.html

No you don't need to have the latest Ubuntu 19 

>  
>>
>>

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8d575edb-65a0-4d98-b6d7-c6a0ca349ac8%40googlegroups.com.


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-19 Thread Tony Wong
doesnt look like i can do it from apt on ubuntu 18

I need ubuntu 19 for ansible 2.9?

On Sun, Apr 19, 2020 at 1:54 PM David Foley  wrote:

> Can you Install Ansible 2.9 on a Test Machine and Retest on this version ?
>
>
>>> --
> 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-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/dd7813fa-88fd-4a75-8112-3dce3819459b%40googlegroups.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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALmkhkqYk1Kk-vSZFEiRa7Yet0dAD%3D4Lc7UOH3ixZRxc1sv%3DvA%40mail.gmail.com.


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-19 Thread David Foley
Can you Install Ansible 2.9 on a Test Machine and Retest on this version ? 


>>

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/dd7813fa-88fd-4a75-8112-3dce3819459b%40googlegroups.com.


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-19 Thread Tony Wong
it is already indented

On Sun, Apr 19, 2020 at 12:47 PM Stefan Hornburg (Racke) 
wrote:

> On 4/19/20 9:13 PM, Tony Wong wrote:
> > Screen Shot 2020-04-19 at 12.10.46 PM.png
> >
> >
> >
> > tony@ubuntu:~/ansiblework$ ansible-playbook vmware_tools.yml
> >  [WARNING]: provided hosts list is empty, only localhost is available.
> Note that the implicit localhost does not match 'all'
> >
> > ERROR! no action detected in task. This often indicates a misspelled
> module name, or incorrect module path.
> >
> > The error appears to be in '/home/tony/ansiblework/vmware_tools.yml':
> line 7, column 5, but may
> > be elsewhere in the file depending on the exact syntax problem.
> >
> > The offending line appears to be:
> >
> >   tasks:
> >   - name: get info about the virtual machine
> > ^ here
> >
>
> The task need to be indented:
>
> tasks:
>   - name: get info about the virtual machine
>
> Regards
>  Racke
>
> >
> >
> > On Saturday, April 18, 2020 at 11:32:04 PM UTC-7, Kiran Kumar wrote:
> >
> > Use https://onlineyamltools.com/validate-yaml <
> https://onlineyamltools.com/validate-yaml>
> >
> > This will help you validate the syntax
> >
> > On Saturday, April 18, 2020 at 2:26:10 PM UTC-7, Tony Wong wrote:
> >
> > this is what i have. but still not working
> >
> > On Sat, Apr 18, 2020 at 1:55 PM David Foley 
> wrote:
> >
> > Why Aren't you using your Local Machine using Atom or VS
> Code to build your Yaml files then using WinSCP
> > copy the playbooks over ?
> >
> > On Saturday, April 18, 2020 at 9:43:00 PM UTC+1, Tony Wong
> wrote:
> >
> > what editor can i use on my ubuntu box? I cant use
> anything other than vim.
> >
> >
> > still getting the error.
> >
> > tony@ubuntu:~/ansiblework$ ansible-playbook info.yml
> >  [WARNING]: provided hosts list is empty, only localhost
> is available. Note that the implicit localhost
> > does not match 'all'
> >
> > ERROR! Syntax Error while loading YAML.
> >   mapping values are not allowed in this context
> >
> > The error appears to be in
> '/home/tony/ansiblework/info.yml': line 3, column 8, but may
> > be elsewhere in the file depending on the exact syntax
> problem.
> >
> > The offending line appears to be:
> >
> > name: get info vm
> >   hosts: localhost
> >^ here
> >
> > On Sat, Apr 18, 2020 at 1:26 PM David Foley <
> david...@mycit.ie> wrote:
> >
> > ---
> > - name: get info vm
> >   hosts: localhost
> >   connection: local
> >   gather_facts: false
> >   tasks:
> >   - name: get info about the virtual machine
> > vmware_guest_info:
> >   hostname: vcnerter
> >   username:
> >   password: 
> >   datacenter: DC
> >   validate_certs: False
> >   name: myvm
> >   schema: "vsphere"
> >
>properties: ["config.hardware.memoryMB", "guest.disk", "overallStatus"]
> > delegate_to: localhost
> > register: info
> >
> >
> > --
> > 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...@googlegroups.com.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/3000e6a2-0db0-4bd5-8fba-ec114f5240e4%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/3000e6a2-0db0-4bd5-8fba-ec114f5240e4%40googlegroups.com?utm_medium=email_source=footer
> >.
> >
> > --
> > 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...@googlegroups.com.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/672cc33a-758f-4083-a48b-0882cb11e453%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/672cc33a-758f-4083-a48b-0882cb11e453%40googlegroups.com?utm_medium=email_source=footer
> >.
> >
> > --
> > 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
> > 

Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-19 Thread Stefan Hornburg (Racke)
On 4/19/20 9:13 PM, Tony Wong wrote:
> Screen Shot 2020-04-19 at 12.10.46 PM.png
> 
> 
> 
> tony@ubuntu:~/ansiblework$ ansible-playbook vmware_tools.yml
>  [WARNING]: provided hosts list is empty, only localhost is available. Note 
> that the implicit localhost does not match 'all'
> 
> ERROR! no action detected in task. This often indicates a misspelled module 
> name, or incorrect module path.
> 
> The error appears to be in '/home/tony/ansiblework/vmware_tools.yml': line 7, 
> column 5, but may
> be elsewhere in the file depending on the exact syntax problem.
> 
> The offending line appears to be:
> 
>   tasks:
>   - name: get info about the virtual machine
>     ^ here
> 

The task need to be indented:

tasks:
  - name: get info about the virtual machine

Regards
 Racke

> 
> 
> On Saturday, April 18, 2020 at 11:32:04 PM UTC-7, Kiran Kumar wrote:
> 
> Use https://onlineyamltools.com/validate-yaml 
> 
> 
> This will help you validate the syntax 
> 
> On Saturday, April 18, 2020 at 2:26:10 PM UTC-7, Tony Wong wrote:
> 
> this is what i have. but still not working
> 
> On Sat, Apr 18, 2020 at 1:55 PM David Foley  wrote:
> 
> Why Aren't you using your Local Machine using Atom or VS Code to 
> build your Yaml files then using WinSCP
> copy the playbooks over ? 
> 
> On Saturday, April 18, 2020 at 9:43:00 PM UTC+1, Tony Wong wrote:
> 
> what editor can i use on my ubuntu box? I cant use anything 
> other than vim. 
> 
> 
> still getting the error. 
> 
> tony@ubuntu:~/ansiblework$ ansible-playbook info.yml
>  [WARNING]: provided hosts list is empty, only localhost is 
> available. Note that the implicit localhost
> does not match 'all'
> 
> ERROR! Syntax Error while loading YAML.
>   mapping values are not allowed in this context
> 
> The error appears to be in '/home/tony/ansiblework/info.yml': 
> line 3, column 8, but may
> be elsewhere in the file depending on the exact syntax 
> problem.
> 
> The offending line appears to be:
> 
> name: get info vm
>   hosts: localhost
>        ^ here
> 
> On Sat, Apr 18, 2020 at 1:26 PM David Foley 
>  wrote:
> 
> ---
> - name: get info vm
>   hosts: localhost
>   connection: local
>   gather_facts: false
>   tasks:
>   - name: get info about the virtual machine
> vmware_guest_info:
>   hostname: vcnerter
>   username: 
>   password: 
>   datacenter: DC
>   validate_certs: False
>   name: myvm
>   schema: "vsphere"
>   properties: ["config.hardware.memoryMB", 
> "guest.disk", "overallStatus"]
> delegate_to: localhost
> register: info
>   
> 
> -- 
> 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...@googlegroups.com.
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/ansible-project/3000e6a2-0db0-4bd5-8fba-ec114f5240e4%40googlegroups.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 ansible...@googlegroups.com.
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/ansible-project/672cc33a-758f-4083-a48b-0882cb11e453%40googlegroups.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
> ansible-project+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit
> 

Re: [ansible-project] Re: How to mix a reboot handler with a service restart handler in the same Ansible playbook?

2020-04-19 Thread Stefan Hornburg (Racke)
On 4/19/20 12:25 PM, David Foley wrote:
> Looking at Ansible Reboot a Machine:
> 
> - name: Reboot a slow machine that might have lots of updates to apply
>   reboot:
> reboot_timeout: 3600
> 
> This will Reboot the System and Test the connection: I wonder if you do a 
> Timeout of zero: default is 6000 what happens
> if you set this to zero,
> 
> Also the Return Valuefrom the above is
> 
> *rebooted* 
> 
> boolean
>   always  
> true if the machine was rebooted
> 
> *Sample:*
> True
> 
> 
> I haven't Tested this code:
> 
> - name: Reboot a slow machine that might have lots of updates to apply 
> reboot: reboot_timeout: 3600 register: reboot -
> debug: var: reboot.rebooted - name: Service Restart service: name: httpd 
> state: restarted when: "{{ reboot }}" == no
> 

The conditions for when and friends are virtually wrapped in a Jinja template, 
thus curly braces are wrong here.

But you can apply when conditions to handlers as well:

- name: restart ssh
  service:
name: ssh
state: restarted
  when: not reboot.rebooted

It is fragile though, as it depends on the order of the handlers which is per 
se unknown.

Regards
 Racke


> 
> 
> -- 
> 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-project+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/6251ea49-de6e-4b1e-82c3-2be23dd15dfb%40googlegroups.com
> .


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

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/711538fe-7643-af27-2984-78952a36eb71%40linuxia.de.


signature.asc
Description: OpenPGP digital signature


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-19 Thread Tony Wong
tony@ubuntu:~/ansiblework$ ansible --version
ansible 2.8.2
  config file = /home/tony/ansiblework/ansible.cfg
  configured module search path = [u'/home/tony/ansiblework/library']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.16 (default, Apr  9 2019, 04:50:39) [GCC 8.3.0]

On Sat, Apr 18, 2020 at 2:57 PM Dick Visser  wrote:

> What does 'ansible --version' say?
>
> On Sat, 18 Apr 2020 at 23:26, Tony Wong  wrote:
>
>> this is what i have. but still not working
>>
>> On Sat, Apr 18, 2020 at 1:55 PM David Foley  wrote:
>>
>>> Why Aren't you using your Local Machine using Atom or VS Code to build
>>> your Yaml files then using WinSCP copy the playbooks over ?
>>>
>>> On Saturday, April 18, 2020 at 9:43:00 PM UTC+1, Tony Wong wrote:

 what editor can i use on my ubuntu box? I cant use anything other than
 vim.


 still getting the error.

 tony@ubuntu:~/ansiblework$ ansible-playbook info.yml
  [WARNING]: provided hosts list is empty, only localhost is available.
 Note that the implicit localhost does not match 'all'

 ERROR! Syntax Error while loading YAML.
   mapping values are not allowed in this context

 The error appears to be in '/home/tony/ansiblework/info.yml': line 3,
 column 8, but may
 be elsewhere in the file depending on the exact syntax problem.

 The offending line appears to be:

 name: get info vm
   hosts: localhost
^ here

 On Sat, Apr 18, 2020 at 1:26 PM David Foley  wrote:

> ---
> - name: get info vm
>   hosts: localhost
>   connection: local
>   gather_facts: false
>   tasks:
>   - name: get info about the virtual machine
> vmware_guest_info:
>   hostname: vcnerter
>   username:
>   password: 
>   datacenter: DC
>   validate_certs: False
>   name: myvm
>   schema: "vsphere"
>   properties: ["config.hardware.memoryMB", "guest.disk",
> "overallStatus"]
> delegate_to: localhost
> register: info
>
>
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/3000e6a2-0db0-4bd5-8fba-ec114f5240e4%40googlegroups.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 ansible-project+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/672cc33a-758f-4083-a48b-0882cb11e453%40googlegroups.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 ansible-project+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CALmkhko58CP5KrYDHK6gBmqdnpqDS0f%2B-Q5hhE37QQ62fHe%2BGQ%40mail.gmail.com
>> 
>> .
>>
> --
> Sent from a mobile device - please excuse the brevity, spelling and
> punctuation.
>
> --
> 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-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAL8fbwMSddLS4fxT1btN%2B99-pz_fZ5M%2BLjhiKoH9c7ZbNwiHOw%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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CALmkhkoKcaPkLW-EPvEqzUnAr68ga%3DY4siqoNzXhMbg9cnrRMQ%40mail.gmail.com.


[ansible-project] Re: How to mix a reboot handler with a service restart handler in the same Ansible playbook?

2020-04-19 Thread David Foley
Looking at Ansible Reboot a Machine:

- name: Reboot a slow machine that might have lots of updates to apply
  reboot:
reboot_timeout: 3600

This will Reboot the System and Test the connection: I wonder if you do a 
Timeout of zero: default is 6000 what happens if you set this to zero, 

Also the Return Value from the above is 

*rebooted*  

boolean
always 
true if the machine was rebooted

*Sample:*
True


I haven't Tested this code:

- name: Reboot a slow machine that might have lots of updates to apply
  reboot:
reboot_timeout: 3600
  register: reboot

  - debug:
  var: reboot.rebooted

- name: Service Restart
  service:
name: httpd
state: restarted
  when: "{{ reboot }}" == no



   

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6251ea49-de6e-4b1e-82c3-2be23dd15dfb%40googlegroups.com.


[ansible-project] How to mix a reboot handler with a service restart handler in the same Ansible playbook?

2020-04-19 Thread Ricardo Amaral
 I'm writing an Ansible playbook to set up my Raspberry Pi so that I can 
keep a versioned configuration and a way for me to quickly get a Pi up and 
running in case I need to reset it or start from scratch.


This playbook has a bunch of tasks where some of them (very few) notify a 
handler to reboot the system while others notify different handlers to 
restart different services (due to configuration changes to those services).


Given how my playbook/roles/tasks as structured, the reboot handler is the 
"first handler in the list", which means it will be the first one to be 
executed at the end of the playbook, followed by the rest of the handlers.


The problem is that if the system reboots, Ansible will wait for the system 
to be back up and continue firing all handlers, like service restarts. The 
thing is, the services were restarted when the system rebooted, there's no 
need to restart them again.


I mean, if the system is going to reboot (the task changed something), 
handlers for service restarts don't need to run (if their tasks changed 
anything), just reboot the system. But if the task which requires a system 
reboot didn't change anything but the task that requires a service restart 
changed something, then that task handler needs to fire.


How can I do this?

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/affa9a24-9292-492b-baac-80e09177f2cd%40googlegroups.com.


Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-19 Thread Karl Auer
I've offered all the help I can. Your best bet is to contact the people who
wrote the program you are trying to use.

You may find it easier to do things like set environment variables and
redirect output using the shell module:

https://docs.ansible.com/ansible/latest/modules/shell_module.html#shell-module

Also, it would be a VERY good idea to test things out manually before
trying to do them in Ansible.

Good luck, K.


On Sun, Apr 19, 2020 at 4:26 PM Samir Kothawade 
wrote:

>
>
> On Sun, 19 Apr 2020 at 05:24, Karl Auer  wrote:
>
>> TERM=dumb
>>
>> Sorry, I mistyped. The minus sign should have been an equals sign.
>>
>> >> >> Can you please help me where I can use this in my code and see the
> content in a text file ? Here is  my anible code...pasting it here again
>  *-** hosts: sam*
> *  gather_facts: no*
> *  tasks:*
> *  - name: capture all stats*
> *ignore_errors: yes*
> *expect:*
> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
> *  responses:*
> *(.*)Username:(.*): "admin"*
> *(.*)Password:(.*): "admin"*
> *(.*)xyz_cli>(.*): display all debug stats*
> *(.*):(.*): ''*
> *register: stats*
> *  - local_action: copy content="{{ stats.stdout}}"
> dest="/home/sam/quickstats/stats.txt"*
> *ignore_errors: yes*
>
>> The idea is to set the environment variable TERM to the value "dumb"
>> immediately before starting the shell in which your program will be run.
>>
>> Also can you please answer the question about whether you can redirect
>> the output of this program?
>>
>
> >> NO. There no support on that binary to copy or to point the output to
> some file. Shell commads like " >>abc.txt " does not work.
>
>>
>> I strongly suggest you experiment manually rather than with Ansible. You
>> need to find out how to achieve what you want, then duplicate that in
>> Ansible. Doing both at once is very painful.
>>
>>
> >>  Yes. I have done this manually.
> *For collecting stats manually here is the procedure :*
> 1. I use mouse > Select the area of stats appeared on screen (after
> selecting area, termius utility copy the selected area automatically) >
> 2. Paste it manually by pressing ctr+v into sublime text editor
> 3. Again go to remote machine and press down key/Enter key to collect
> remaining stats and copy-paste the status in similarly way as mentioed in
> step 1 and 2.
> 4. I have to perform step 1,2,3 multiple times untill I copy all the
> status, as window can display only 25-30 lines/rows. Some times for doing
> it quickly, I use zoom-out (Ctr++), by this I can copy more lines.
> But I want to do this operation through automation.
>
>> Regards, K.
>>
>> On Sun, Apr 19, 2020 at 2:34 AM Samir Kothawade <
>> kothawade.sa...@gmail.com> wrote:
>>
>>> bash: TERM-dumb: command not found.
>>>
>>> gnome-terminal utility not available on remote  machine
>>>
>>>
>>> On Sat, 18 Apr 2020 at 21:53, Karl Auer  wrote:
>>>
 You *might* be able to convince the console on the remote system to be
 a dumb terminal by doing this as your command:

 TERM-dumb ; sh -c your_command

 This works in gnome-terminal as well - it seems to suppress most
 control sequences except CR/LF and similar.

 Or in Ansible, setting the environment variable TERM to "dumb" then
 running your command in a new shell. In my experiments here, when I set
 TERM=dumb and ran sh from within a console or from within
 gnome-terminal, the colourisation went away. However the console still
 had a fixed number of lines.

 Regards, K.

 On Sun, Apr 19, 2020 at 1:04 AM Samir Kothawade <
 kothawade.sa...@gmail.com> wrote:

>
>
> >> Could you please explain how can use xterm command : xterm --tn
> dumb -cm -dc -e this is your command
>Fustratigly, xterm is not present in remote  machine and I am not
> allowed to install xterm utility on targeted remote machine. Still, is
> there any way to run it through ansible conroller?
>
>
> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>>
>> Hi,
>>
>> *Here is the brief about scenario: *
>>
>> 1. login to Debian host machine using ansible
>> 2. Go to corresponding directory where the binary is and execute that
>> binary. (This binary is written in c and C++. After execution it ask for
>> the userid & password)
>> 3. After login into that binary's shell, it  has several commands
>> which displays statistics. Those stats are lengthy and does not fit in
>> current screen resolution. For seen seeing all the stats we have to press
>> Down arrow Key or Enter key multiple time until we reach to last stat 
>> line.
>>
>> *How I am doing this: *
>>
>> *-** hosts: sam*
>> *  gather_facts: no*
>> *  tasks:*
>> *  - name: capture all stats*
>> *ignore_errors: yes*
>> *expect:*
>> *  command: 

Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-19 Thread Stefan Hornburg (Racke)
On 4/19/20 8:25 AM, Samir Kothawade wrote:
> 
> 

Hello Samir,

this is now really off topic. Try to figure out to wrangle the data out of this 
rather unhelpful binary
by means of "expect" or similar software, but your problem is not related to 
Ansible.

Regards
 Racke

> On Sun, 19 Apr 2020 at 05:24, Karl Auer  > wrote:
> 
> TERM=dumb
> 
> Sorry, I mistyped. The minus sign should have been an equals sign.
> 
>>> >> Can you please help me where I can use this in my code and see the 
>>> >> content in a text file ? Here is  my anible
> code...pasting it here again
>  /-// hosts: sam/
> /  gather_facts: no/
> /  tasks:/
> /  - name: capture all stats/
> /    ignore_errors: yes/
> /    expect:/
> /      command: /opt/abc/xyz_Platform/bin/go_xyz_cli/
> /      responses:/
> /        (.*)Username:(.*): "admin"/
> /        (.*)Password:(.*): "admin"/
> /        (.*)xyz_cli>(.*): display all debug stats/
> /  *      (.*):(.*): ''*//* */
> /    register: stats/
> /  - local_action: copy content="{{ stats.stdout}}" 
> dest="/home/sam/quickstats/stats.txt"/
> /    ignore_errors: yes/ 
> 
> The idea is to set the environment variable TERM to the value "dumb" 
> immediately before starting the shell in which
> your program will be run.
> 
> Also can you please answer the question about whether you can redirect 
> the output of this program?
> 
> 
>>> NO. There no support on that binary to copy or to point the output to some 
>>> file. Shell commads like " >>abc.txt "
> does not work.
> 
> 
> I strongly suggest you experiment manually rather than with Ansible. You 
> need to find out how to achieve what you
> want, then duplicate that in Ansible. Doing both at once is very painful.
> 
> 
>>>  Yes. I have done this manually.
> *_For collecting stats manually here is the procedure :_*
> 1. I use mouse > Select the area of stats appeared on screen (after selecting 
> area, termius utility copy the selected
> area automatically) >
> 2. Paste it manually by pressing ctr+v into sublime text editor 
> 3. Again go to remote machine and press down key/Enter key to collect 
> remaining stats and copy-paste the status in
> similarly way as mentioed in step 1 and 2. 
> 4. I have to perform step 1,2,3 multiple times untill I copy all the status, 
> as window can display only 25-30
> lines/rows. Some times for doing it quickly, I use zoom-out (Ctr++), by this 
> I can copy more lines. 
>     But I want to do this operation through automation.    
> 
> Regards, K.
> 
> On Sun, Apr 19, 2020 at 2:34 AM Samir Kothawade 
> mailto:kothawade.sa...@gmail.com>> wrote:
> 
> bash: TERM-dumb: command not found.
> 
> gnome-terminal utility not available on remote  machine
> 
> 
> On Sat, 18 Apr 2020 at 21:53, Karl Auer  > wrote:
> 
> You *might* be able to convince the console on the remote system 
> to be a dumb terminal by doing this as your
> command:
> 
> TERM-dumb ; sh -c your_command
> 
> This works in gnome-terminal as well - it seems to suppress most 
> control sequences except CR/LF and similar.
> 
> Or in Ansible, setting the environment variable TERM to "dumb" 
> then running your command in a new shell. In
> my experiments here, when I set TERM=dumb and ran sh from within 
> a console or from within gnome-terminal,
> the colourisation went away. However the console still had a 
> fixed number of lines.
> 
> Regards, K.
> 
> On Sun, Apr 19, 2020 at 1:04 AM Samir Kothawade 
>  > wrote:
> 
> 
> 
> >> Could you please explain how can use xterm command : xterm 
> --tn dumb -cm -dc -e this is your command
>    Fustratigly, xterm is not present in remote  machine and I 
> am not allowed to install xterm utility on
> targeted remote machine. Still, is there any way to run it 
> through ansible conroller?
> 
> 
> On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade 
> wrote:
> 
> Hi, 
> 
> *_Here is the brief about scenario: _*
> 
> 1. login to Debian host machine using ansible
> 2. Go to corresponding directory where the binary is and 
> execute that binary. (This binary is
> written in c and C++. After execution it ask for the 
> userid & password) 
> 3. After login into that binary's shell, it  has several 
> commands which displays statistics. Those
> stats are lengthy and does not fit in current screen 
> resolution. For seen seeing all the stats we
> have to press Down arrow Key or Enter key multiple time 
> until we reach to last stat line.
> 
> _*How I am doing this: *_
> 
> /-//hosts: 

Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-19 Thread Kiran Kumar
Use https://onlineyamltools.com/validate-yaml

This will help you validate the syntax 

On Saturday, April 18, 2020 at 2:26:10 PM UTC-7, Tony Wong wrote:
>
> this is what i have. but still not working
>
> On Sat, Apr 18, 2020 at 1:55 PM David Foley  > wrote:
>
>> Why Aren't you using your Local Machine using Atom or VS Code to build 
>> your Yaml files then using WinSCP copy the playbooks over ? 
>>
>> On Saturday, April 18, 2020 at 9:43:00 PM UTC+1, Tony Wong wrote:
>>>
>>> what editor can i use on my ubuntu box? I cant use anything other than 
>>> vim. 
>>>
>>>
>>> still getting the error. 
>>>
>>> tony@ubuntu:~/ansiblework$ ansible-playbook info.yml
>>>  [WARNING]: provided hosts list is empty, only localhost is available. 
>>> Note that the implicit localhost does not match 'all'
>>>
>>> ERROR! Syntax Error while loading YAML.
>>>   mapping values are not allowed in this context
>>>
>>> The error appears to be in '/home/tony/ansiblework/info.yml': line 3, 
>>> column 8, but may
>>> be elsewhere in the file depending on the exact syntax problem.
>>>
>>> The offending line appears to be:
>>>
>>> name: get info vm
>>>   hosts: localhost
>>>^ here
>>>
>>> On Sat, Apr 18, 2020 at 1:26 PM David Foley  wrote:
>>>
 ---
 - name: get info vm
   hosts: localhost
   connection: local
   gather_facts: false
   tasks:
   - name: get info about the virtual machine
 vmware_guest_info:
   hostname: vcnerter
   username: 
   password: 
   datacenter: DC
   validate_certs: False
   name: myvm
   schema: "vsphere"
   properties: ["config.hardware.memoryMB", "guest.disk", 
 "overallStatus"]
 delegate_to: localhost
 register: info
   

 -- 
 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...@googlegroups.com.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/ansible-project/3000e6a2-0db0-4bd5-8fba-ec114f5240e4%40googlegroups.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 ansible...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/672cc33a-758f-4083-a48b-0882cb11e453%40googlegroups.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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d173cf22-37f8-4b7f-9e08-f2813ed4b5f2%40googlegroups.com.


Re: [ansible-project] Check status of VMware tools & reboot if VMware tools are not running

2020-04-19 Thread Kiran Kumar
Thanks Abhijeet ! 

On Friday, April 17, 2020 at 1:26:53 AM UTC-7, Abhijeet Kasurde wrote:
>
> ---
> - hosts: localhost
> vars_files:
> - vcenter_vars.yml
> vars:
> vm_list:
> - test01
> tasks:
> - name: Get information about the virtual machine
> vmware_guest_info:
> validate_certs: False
> hostname: '{{ vcenter_hostname }}'
> username: '{{ vcenter_username }}'
> password: '{{ vcenter_password }}'
> folder: /Asia-Datacenter1/vm/
> name: "{{ item }}"
> datacenter: Asia-Datacenter1
> register: vm_info
> with_items: "{{ vm_list }}"
>
> - name: Get Tools status
> set_fact:
> desired_vms: "{{ vm_info.results | json_query(jmesquery) }}"
> vars:
> jmesquery: "[?instance.guest_tools_status == 
> 'guestToolsNotRunning'].instance.hw_name"
>
> - name: Reboot the given VM
> vmware_guest_powerstate:
> validate_certs: False
> hostname: '{{ vcenter_hostname }}'
> username: '{{ vcenter_username }}'
> password: '{{ vcenter_password }}'
> folder: /Asia-Datacenter1/vm/
> name: "{{ item }}"
> state: 'reboot-guest'
> with_items: "{{ desired_vms }}"
>
>
>
> On Fri, Apr 17, 2020 at 1:00 PM Kiran Kumar  > wrote:
>
>> Hi
>>
>>
>> I need to check status of VMware tools on vms & if VMware tools are not 
>> running, then reboot the vm. I have below playbook which works fine to find 
>> vm name & VMware tools status. Please help on how can i extract the vm name 
>> & take action as per status.  
>>
>> Note : i have to use the VMware modules as the OS typically will be in 
>> hung status ( hence tools not running ) , hence avoid user OS level task ( 
>> and use VMware task ) 
>>
>> Thanks 
>>
>> ---
>>> - hosts: localhost
>>>   gather_facts: false
>>>   connection: local
>>>   collections:
>>>   - community.vmware
>>>   - community.general
>>>   vars_files:
>>> - ./vars/vmware_vars.yml
>>>   vars:
>>> vm_list:
>>>   - vm1
>>>   - vm2
>>>   tasks:
>>> - name: Gather VM info
>>>   vmware_guest_info:
>>> hostname: "{{ vcenter_server }}"
>>> username: "{{ vcenter_user }}"
>>> password: "{{ vcenter_pass }}"
>>> datacenter: "{{ vcenter_datacenter }}"
>>> validate_certs: no
>>> name: "{{ item }}"
>>>   register: vm_info
>>>   with_items: "{{ vm_list }}"
>>> - name: Tools status all
>>>   debug:
>>> msg: "{{ vm_info.results  | json_query(jmesquery) }}"
>>>   vars:
>>> jmesquery: "[?instance.hw_name == '{{ item 
>>> }}'].instance.guest_tools_status"
>>>   with_items: "{{ vm_list }}"
>>
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/3473c234-0db3-4808-b73d-d9ba8460b5ee%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> Thanks,
> Abhijeet Kasurde
>

-- 
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-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/8768fe59-44ab-45e4-a778-c3e60ac8a957%40googlegroups.com.


Re: [ansible-project] Re: How to change remote hosts' terminal screen size/resolution in Ansible

2020-04-19 Thread Samir Kothawade
On Sun, 19 Apr 2020 at 05:24, Karl Auer  wrote:

> TERM=dumb
>
> Sorry, I mistyped. The minus sign should have been an equals sign.
>
> >> >> Can you please help me where I can use this in my code and see the
content in a text file ? Here is  my anible code...pasting it here again
 *-** hosts: sam*
*  gather_facts: no*
*  tasks:*
*  - name: capture all stats*
*ignore_errors: yes*
*expect:*
*  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
*  responses:*
*(.*)Username:(.*): "admin"*
*(.*)Password:(.*): "admin"*
*(.*)xyz_cli>(.*): display all debug stats*
*(.*):(.*): ''*
*register: stats*
*  - local_action: copy content="{{ stats.stdout}}"
dest="/home/sam/quickstats/stats.txt"*
*ignore_errors: yes*

> The idea is to set the environment variable TERM to the value "dumb"
> immediately before starting the shell in which your program will be run.
>
> Also can you please answer the question about whether you can redirect the
> output of this program?
>

>> NO. There no support on that binary to copy or to point the output to
some file. Shell commads like " >>abc.txt " does not work.

>
> I strongly suggest you experiment manually rather than with Ansible. You
> need to find out how to achieve what you want, then duplicate that in
> Ansible. Doing both at once is very painful.
>
>
>>  Yes. I have done this manually.
*For collecting stats manually here is the procedure :*
1. I use mouse > Select the area of stats appeared on screen (after
selecting area, termius utility copy the selected area automatically) >
2. Paste it manually by pressing ctr+v into sublime text editor
3. Again go to remote machine and press down key/Enter key to collect
remaining stats and copy-paste the status in similarly way as mentioed in
step 1 and 2.
4. I have to perform step 1,2,3 multiple times untill I copy all the
status, as window can display only 25-30 lines/rows. Some times for doing
it quickly, I use zoom-out (Ctr++), by this I can copy more lines.
But I want to do this operation through automation.

> Regards, K.
>
> On Sun, Apr 19, 2020 at 2:34 AM Samir Kothawade 
> wrote:
>
>> bash: TERM-dumb: command not found.
>>
>> gnome-terminal utility not available on remote  machine
>>
>>
>> On Sat, 18 Apr 2020 at 21:53, Karl Auer  wrote:
>>
>>> You *might* be able to convince the console on the remote system to be a
>>> dumb terminal by doing this as your command:
>>>
>>> TERM-dumb ; sh -c your_command
>>>
>>> This works in gnome-terminal as well - it seems to suppress most
>>> control sequences except CR/LF and similar.
>>>
>>> Or in Ansible, setting the environment variable TERM to "dumb" then
>>> running your command in a new shell. In my experiments here, when I set
>>> TERM=dumb and ran sh from within a console or from within gnome-terminal,
>>> the colourisation went away. However the console still had a fixed number
>>> of lines.
>>>
>>> Regards, K.
>>>
>>> On Sun, Apr 19, 2020 at 1:04 AM Samir Kothawade <
>>> kothawade.sa...@gmail.com> wrote:
>>>


 >> Could you please explain how can use xterm command : xterm --tn
 dumb -cm -dc -e this is your command
Fustratigly, xterm is not present in remote  machine and I am not
 allowed to install xterm utility on targeted remote machine. Still, is
 there any way to run it through ansible conroller?


 On Saturday, 18 April 2020 14:45:18 UTC+5:30, Samir Kothawade wrote:
>
> Hi,
>
> *Here is the brief about scenario: *
>
> 1. login to Debian host machine using ansible
> 2. Go to corresponding directory where the binary is and execute that
> binary. (This binary is written in c and C++. After execution it ask for
> the userid & password)
> 3. After login into that binary's shell, it  has several commands
> which displays statistics. Those stats are lengthy and does not fit in
> current screen resolution. For seen seeing all the stats we have to press
> Down arrow Key or Enter key multiple time until we reach to last stat 
> line.
>
> *How I am doing this: *
>
> *-** hosts: sam*
> *  gather_facts: no*
> *  tasks:*
> *  - name: capture all stats*
> *ignore_errors: yes*
> *expect:*
> *  command: /opt/abc/xyz_Platform/bin/go_xyz_cli*
> *  responses:*
> *(.*)Username:(.*): "admin"*
> *(.*)Password:(.*): "admin"*
> *(.*)xyz_cli>(.*): display all debug stats*
> *(.*):(.*): ''*
> *register: stats*
> *  - local_action: copy content="{{ stats.stdout}}"
> dest="/home/sam/quickstats/stats.txt"*
> *ignore_errors: yes*
>
>
> *Issues Facing : *
>
> 1. Multiple similar line gets copied in stats.txt file when above
> reaches to ==>>*  (.*):(.*): ''*  (See above code section marked in
> blue). Using this method to press  key.
> 2. Actual stats counts are of line 500 hundred but above code