Re: [ansible-project] When condition help - Skip if service running

2022-08-26 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Think it through .. what is the structure of the data in 'lg' after win_service? You have to learn to decipher structured data so you can learn how to reference it. Walter -- Walter Rowe, Division Chief Infrastructure Services, OISM Mobile: 202.355.4123 On Aug 26, 2022, at 12:13 PM, Nitrous

Re: [ansible-project] When condition help - Skip if service running

2022-08-26 Thread Nitrous
Yes, its the same information I gathered previously. I need to search for this string in my when condition: "exists": true How can I do that? Thanks On Friday, August 26, 2022 at 10:59:12 AM UTC-5 walte...@nist.gov wrote: > Please read the module page for a description of what is "registered"

Re: [ansible-project] When condition help - Skip if service running

2022-08-26 Thread Nitrous
How can I search for this exact string using my example: "exists": true My when condition: when: lg is search( "exists": true ) It errors out using "exists": true. On Friday, August 26, 2022 at 9:27:53 AM UTC-5 Nitrous wrote: > Thanks, but I have other tasks that depend on my when

Re: [ansible-project] When condition help - Skip if service running

2022-08-26 Thread Nitrous
Thanks, but I have other tasks that depend on my when condition, so I need to get it right. On Friday, August 26, 2022 at 9:22:37 AM UTC-5 pgm...@gmail.com wrote: > > https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_service_info_module.html > > On Fri, Aug 26, 2022 at

Re: [ansible-project] When condition help - Skip if service running

2022-08-26 Thread Paul Manno
https://docs.ansible.com/ansible/latest/collections/ansible/windows/win_service_info_module.html On Fri, Aug 26, 2022 at 9:17 AM Nitrous wrote: > Im trying to figure out a way, on how to make a condition exit, if a > service is running. > If it isnt running, then install it. > > My play book

[ansible-project] When condition help - Skip if service running

2022-08-26 Thread Nitrous
Im trying to figure out a way, on how to make a condition exit, if a service is running. If it isnt running, then install it. My play book looks like below: - name: Check if LogRhythm System Monitor service is installed win_service: name: lg register: lg - ansible.builtin.debug:

Re: [ansible-project] when condition based on software version

2022-01-30 Thread Vladimir Botka
On Sat, 29 Jan 2022 05:05:39 -0800 (PST) John Veliss wrote: > I would like to include some ansible *"when"* conditions based on if a > software package is greater than a value ... Set default to 'undef' if the package is missing, e.g. - package_facts: - set_fact: _version: "{{

[ansible-project] when condition based on software version

2022-01-29 Thread John Veliss
I would like to include some ansible *"when"* conditions based on if a software package is greater than a value, ie when a package is greater than 8.2, perform a task such as stop a service, uninstall the package, copy a file, install a new version of the package I have the below which shows

Re: [ansible-project] when condition is not working

2021-10-01 Thread subbamma natla
sorry. I take it back my words the following change is working when: htop_is_running.stdout == '0' Thanks On Friday, October 1, 2021 at 8:05:29 AM UTC-4 ra...@linuxia.de wrote: > On 01/10/2021 14:53, Sandip Bhattacharya wrote: > > > > > > On 01.10.21 02:10, subbamma natla wrote: > >> can

Re: [ansible-project] when condition is not working

2021-10-01 Thread Sandip Bhattacharya
On 01.10.21 15:32, subbamma natla wrote: when: htop_is_running.stdout == '0'   did not work command: pgrep httpd My question is why the following not working  when: status_httpd.stdout_lines == 0 ok: [mhost1] => {     "status_httpd.stdout_lines": [         "0"     ] } If the 'when'

Re: [ansible-project] when condition is not working

2021-10-01 Thread subbamma natla
when: htop_is_running.stdout == '0' did not work command: pgrep httpd My question is why the following not working when: status_httpd.stdout_lines == 0 ok: [mhost1] => { "status_httpd.stdout_lines": [ "0" ] } Thanks On Friday, October 1, 2021 at 9:14:27 AM UTC-4 Sandip

Re: [ansible-project] when condition is not working

2021-10-01 Thread Sandip Bhattacharya
What's wrong with asserting that the service should be started? - systemd:     name: httpd     state: started For the vast majority of cases that should work (the apache service in major distros being such a case). Sometimes you do get an edge case where the PID check in the unit file

Re: [ansible-project] when condition is not working

2021-10-01 Thread Stefan Hornburg (Racke)
On 01/10/2021 14:53, Sandip Bhattacharya wrote: On 01.10.21 02:10, subbamma natla wrote: can somebody explaine me why service sis not starting on mhost1: [root@mhost1 ~]#  ps -ef | grep -v grep | grep httpd It might be cleaner to use pgrep instead for process check. Then you can use

Re: [ansible-project] when condition is not working

2021-10-01 Thread Sandip Bhattacharya
On 01.10.21 02:10, subbamma natla wrote: can somebody explaine me why service sis not starting on mhost1: [root@mhost1 ~]#  ps -ef | grep -v grep | grep httpd It might be cleaner to use pgrep instead for process check. Then you can use something like this: tasks: - name: Process

[ansible-project] when condition is not working

2021-09-30 Thread subbamma natla
can somebody explaine me why service sis not starting on mhost1: [root@mhost1 ~]# ps -ef | grep -v grep | grep httpd [root@mhost1 ~]# --- - hosts: mhost1 tasks: - name: check status httpd shell: ps -ef | grep -v grep | grep httpd|wc -l register: htop_is_running notify:

[ansible-project] When Condition use with Variables

2021-03-26 Thread Pravin V
Hello Everyone, I've a task - - name: Device Description uri: url: "{{ URL }}/api-db?username={{ USERNAME }};password={{ PASSWORD }};cmds=mget+*+{{ display_name }}+sys+SNMPv2-MIB.sysDescr" validate_certs: no method: GET return_content: yes register: get_descriptions

Re: [ansible-project] When condition is failing in windows ansible

2020-03-19 Thread Stefan Hornburg (Racke)
On 3/19/20 9:22 AM, Uppara venkat wrote: > Hi all, > > I have written below task to copy a file if it is 64-bit windows OS.  > > - name: >   win_shell: 'wmic os get osarchitecture |  findstr "bit"' >   register: result > - debug: var=result.stdout_lines   > > - name: >   win_copy: >    

[ansible-project] When condition is failing in windows ansible

2020-03-19 Thread Uppara venkat
Hi all, I have written below task to copy a file if it is 64-bit windows OS. - name: win_shell: 'wmic os get osarchitecture | findstr "bit"' register: result - debug: var=result.stdout_lines - name: win_copy: src='{{package_PATH}}/vim25.zip' dest='{{ vim25_PATH }}/vmware/'

[ansible-project] When condition not working in a list

2019-10-03 Thread Rakesh Parida
Hi, I have yaml file as below. I parse the component and version and put the parsed value to a file by creating a list deliveries: - releases: - latest: - tmoAa: file_name: CXP_902_7801_28.1.0_20191001-024646.tar md5: f08a50fcb3ec79c87ec870195568826e product_name:

Re: [ansible-project] When condition 'or' structure question

2019-09-10 Thread Vladimir Botka
On Tue, 10 Sep 2019 21:16:04 +0200 Kai Stian Olstad wrote: > On 10.09.2019 20:14, Vladimir Botka wrote: > > On Tue, 10 Sep 2019 10:45:45 -0700 > > Guy Knights wrote: > > > >> It's possible to define a series of 'and' conditions for a task as follows: > >> > >>when: > >> - foo ==

Re: [ansible-project] When condition 'or' structure question

2019-09-10 Thread Kai Stian Olstad
On 10.09.2019 20:14, Vladimir Botka wrote: > On Tue, 10 Sep 2019 10:45:45 -0700 > Guy Knights wrote: > >> It's possible to define a series of 'and' conditions for a task as follows: >> >>when: >> - foo == true >> - bar == true >> >> As far as I'm aware, the only way to define 'or'

Re: [ansible-project] When condition 'or' structure question

2019-09-10 Thread Vladimir Botka
On Tue, 10 Sep 2019 10:45:45 -0700 Guy Knights wrote: > It's possible to define a series of 'and' conditions for a task as follows: > > when: > - foo == true > - bar == true > > As far as I'm aware, the only way to define 'or' conditions is in-line, as > such: > > when: foo ==

[ansible-project] When condition 'or' structure question

2019-09-10 Thread Guy Knights
It's possible to define a series of 'and' conditions for a task as follows: when: - foo == true - bar == true As far as I'm aware, the only way to define 'or' conditions is in-line, as such: when: foo == true or bar == true Is there any other way to define 'or' conditions, in a way

[ansible-project] When condition and fetching values

2019-06-05 Thread Tanisha Mishra
I am using csv python module for importing a csv file The csv is importing but unable to fetch the values properly. My main aim is the prompt that takes as server name needs to check from the csv list whether it exists or not... I have to add 'when' condition also, but unable to separate

Re: [ansible-project] When condition to check domainName

2019-04-26 Thread Raj
Thanks for the explanation Brian, you are "Awesome". I've used "When & In" and it worked. On Monday, April 22, 2019 at 9:20:59 PM UTC-5, Brian Coca wrote: > > Mustaches don't stack, > > when: ((domainName == "AD1") or (domainName == "AD2")) <= no > mustaches needed when 'when:', you are

Re: [ansible-project] When condition to check domainName

2019-04-22 Thread Brian Coca
Mustaches don't stack, when: ((domainName == "AD1") or (domainName == "AD2")) <= no mustaches needed when 'when:', you are trying to do double interpolation (conditionals have implicit {{ }}) Also you probably want to use 'in' instead of multiple comparisons: when: domainName in ["AD1",

[ansible-project] When condition to check domainName

2019-04-22 Thread Raj
Hello, I am running into an issue, this is simple playbook which tries to copy right config file based on Domain name, I tried executing below code snippet it's skipping the non prod and executing prod, Not sure whats wrong here, can some one throw a light here. - name: Gathering facts

Re: [ansible-project] When Condition check is not working in a list as expected.

2019-03-01 Thread Pandu jh
Thank you, It worked. On Friday, 1 March 2019 00:50:41 UTC+5:30, Kai Stian Olstad wrote: > > On 28.02.2019 13:52, Pandu jh wrote: > > When Condition check is not working in a list as expected. > > > > My requirement is > > > > Playbook should not fail If all the three mentioned variables

Re: [ansible-project] When Condition check is not working in a list as expected.

2019-02-28 Thread Kai Stian Olstad
On 28.02.2019 13:52, Pandu jh wrote: > When Condition check is not working in a list as expected. > > My requirement is > > Playbook should not fail If all the three mentioned variables have > "no_share" value. > But it's failing not sure what causing this issue. > > > > - debug:

[ansible-project] When Condition check is not working in a list as expected.

2019-02-28 Thread Pandu jh
When Condition check is not working in a list as expected. My requirement is Playbook should not fail If all the three mentioned variables have "no_share" value. But it's failing not sure what causing this issue. - debug: var=open_shares_info - debug: var=linked_dirs_list -

[ansible-project] When condition ignored during the includes and loops

2018-03-06 Thread Raja Shekar
Hello, Can some one help me on below issue, When condition got ignored if I use Includes and loops. main.yml --- - name: Run sqlplus command on Target DB server shell: source ~/.bash_profile && sqlplus -S '{{ admin }}/{{ password }}@{{ deploy_server }}:1521/{{ oracle_db_name }}'

[ansible-project] when condition on a variable starting with a string value

2017-02-07 Thread fanvalt
Hello, Actually I wrote my playbook this way to set values id the dual variable is the string value SRV: - set_fact: distrib: "{{ distribsrv }}" Directoryname: "{{ Directorysrv }}" when: dual == 'SRV' I would like to modify the when condition to run it when dual == 'SRV1',

Re: [ansible-project] WHEN CONDITION

2017-02-07 Thread DHAVAL JAISWAL
Thanks !! It works, post adding set_fact: current_image_state="{{ image_state.stdout }}". On Tue, Feb 7, 2017 at 5:34 PM, Johannes Kastl wrote: > On 06.02.17 20:00 DHAVAL JAISWAL wrote: > > Tried below one. However, when condition is not correctly evaluating. > > Please show

Re: [ansible-project] WHEN CONDITION

2017-02-07 Thread Johannes Kastl
On 06.02.17 20:00 DHAVAL JAISWAL wrote: > Tried below one. However, when condition is not correctly evaluating. Please show the exact error message. Or the exact output, maybe with -v. > tasks: >- name: Get the state of the Test version > shell: alert1=`cat /tmp/test.log | grep -e

Re: [ansible-project] WHEN CONDITION

2017-02-06 Thread DHAVAL JAISWAL
Tried below one. However, when condition is not correctly evaluating. Even following condition true its executing other commands mentioned in other when condition. current_image_state <= desire_image_state tasks: - name: Get the state of the Test version shell: alert1=`cat

Re: [ansible-project] WHEN CONDITION

2017-02-01 Thread Rodrigo B Brasil
This should help: http://docs.ansible.com/ansible/playbooks_variables.html http://docs.ansible.com/ansible/set_fact_module.html []s, Rodrigo B Brasil On Wed, Feb 1, 2017 at 4:16 PM, DHAVAL JAISWAL wrote: > Where i can set this variable so that i can compare it in where

Re: [ansible-project] WHEN CONDITION

2017-02-01 Thread DHAVAL JAISWAL
Where i can set this variable so that i can compare it in where condition. Any small test scenario will help me to understand. On Mon, Jan 30, 2017 at 11:53 PM, Brian Coca wrote: > These are not valid variables for Ansible (not since 1.6). Also, setting > them in a shell

Re: [ansible-project] WHEN CONDITION

2017-01-30 Thread Brian Coca
These are not valid variables for Ansible (not since 1.6). Also, setting them in a shell will not make them available. when: $numami > $num -- Brian Coca -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this

Re: [ansible-project] WHEN CONDITION

2017-01-30 Thread bablu
I did create the small task. However, for defining variable (num, numami) in the same task is not working. e.g tasks: - name: Condition statement shell: date_string=`date +%d%b%G`; num=3; numami=5; when: $numami > $num echo Hi; On Monday, January 30, 2017 at

Re: [ansible-project] WHEN CONDITION

2017-01-30 Thread Brian Coca
Just add a when to the tasks you want in the 'if' when: arg1 > 5 for the 'else' just use the opposite condition. when: arg1 <=5 -- Brian Coca -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop

[ansible-project] WHEN CONDITION

2017-01-30 Thread bablu
I want to use the following condition in ansible playbook. Scenario is as follows. If arg1 > 5 follow some steps else endif; IF ELSE is not possible in ansible. However, how can i achive with the WHEN condition. -- You received this message because

[ansible-project] "when" condition in handler is not honored

2016-06-14 Thread Guy Matz
Hi! I have a "when: condition that works fine in "regular" tasks, but not in a handler . . . is that expected? So I'm using a notify, then at the end of the handler task I have a when condition. The notification works, but it always triggers, ever when the condition is false. Here's the

Re: [ansible-project] When condition

2016-05-03 Thread Johannes Kastl
On 29.04.16 12:08 'Suresh Uppu' via Ansible Project wrote: > - name: installing python setuptools > become: yes > become_method: sudo > yum: name=python-setuptools state=latest > when: ansible_os_family == "RedHat" > zypper: name=python-setuptools state=latest

[ansible-project] When condition

2016-04-29 Thread 'Suresh Uppu' via Ansible Project
Hi, This is Suresh. I am new to Ansible. I have a query, Can I please ask any one to clarify this. I am using when: condition. The below one is working fine. file copy is working fine based on distribution. didnt get any error. " - name: copying clinet install zip to server become:

[ansible-project] when condition based on list

2014-10-24 Thread Jacob Weber
Is it possible to write something like when: a and b and c, but get the list [a,b,c] from a variable? I have one command that outputs some data, which I register in a variable x. Then I want to see if all items from variable y are included in that output. If I were doing it manually, it might

Re: [ansible-project] when condition based on list

2014-10-24 Thread Michael DeHaan
sounds like you mean do something like: when: a in ['x','y','z'] or when: x.foo in alist ?? On Fri, Oct 24, 2014 at 3:50 PM, Jacob Weber weberja...@gmail.com wrote: Is it possible to write something like when: a and b and c, but get the list [a,b,c] from a variable? I have one command

Re: [ansible-project] when condition based on list

2014-10-24 Thread Jacob Weber
Not exactly...I want each condition to be a regex on the output of the original command (which also contains a lot of other text). That's why I was trying to use a search filter. On Oct 24, 2014, at 5:04 PM, Michael DeHaan mich...@ansible.com wrote: sounds like you mean do something like:

[ansible-project] when condition not being evaluated with include statement

2014-08-18 Thread Imran Khan
I have a tikitaka3.yml (main yml file) and a tikitaka3a.yml (playbook to be included) . When I prompt the user for a variable and then in the tasks section when I call it, like so: --- - hosts: all vars: khan: # contents: {{ lookup('file',

Re: [ansible-project] when condition not being evaluated with include statement

2014-08-18 Thread Brian Coca
The when does not affect the include itself, it gets added to all tasks included.​ -- 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] when condition not being evaluated with include statement

2014-08-18 Thread Michael DeHaan
Take a look at the docs of the group_by module if you want some more elegant output based on dynamic criteria. On Mon, Aug 18, 2014 at 7:44 AM, Brian Coca brianc...@gmail.com wrote: The when does not affect the include itself, it gets added to all tasks included.​ -- You received this

Re: [ansible-project] when condition not being evaluated with include statement

2014-08-18 Thread Imran Khan
Basically I want to run my secondary playbook on a specific number of hosts in a specific group (I have shown just one example of a group here i.e. umar, I intend on having three groups) using var_prompts, the group is going to be specified in my main file whereas the logic for particular host

Re: [ansible-project] when condition not being evaluated with include statement

2014-08-18 Thread Michael DeHaan
The group_by module? On Mon, Aug 18, 2014 at 8:42 AM, Imran Khan khan.imran2...@gmail.com wrote: Then what can I do to achieve the functionality that I require? On Monday, August 18, 2014 4:44:18 AM UTC-7, Brian Coca wrote: The when does not affect the include itself, it gets added to all

Re: [ansible-project] when condition

2014-07-20 Thread 'Diogene Laerce' via Ansible Project
Hi Michael, Thanks ! And second hit bird : I know now what my Debian shell means by : cannot stat.. Re-thanks. ;) On 07/18/2014 08:15 PM, Michael DeHaan wrote: You don't use Jinja2 inside when statements. Further, not all python functions, including the OS module, are exposed, and what you

[ansible-project] when condition

2014-07-18 Thread 'Diogene Laerce' via Ansible Project
Hi, I would like to evaluate the following condition : # - name: Make Debian package shell: command=make deb chdir=/home/{{ user_installer }}/src/Python.3.4.1 when: os.path.isdir('/home/{{ user_installer }}/src/Python-3.4.1') == True

Re: [ansible-project] when condition

2014-07-18 Thread Michael DeHaan
You don't use Jinja2 inside when statements. Further, not all python functions, including the OS module, are exposed, and what you are saying would be an implicit local operation anyway. You would need to run the stat module, register the result, and use that - stat: path=/path/to/file