Re: [ansible-project] Add conditionals to debug msg

2017-08-15 Thread Ryan
If i remove async and poll your solution does work.  I was using them 
because depending on the platform the playbook is executed on, the time to 
complete can vary a lot.  I will play around with not using the async and 
poll and see what the result is, as I am still new to Ansible obviously.

Thanks!


On Monday, August 14, 2017 at 3:13:25 PM UTC-7, Kai Stian Olstad wrote:
>
> On 14. aug. 2017 23:58, Ryan wrote: 
> > Thanks for the detailed reply. 
> > 
> >   - name: Check for ECC's 
> > shell: ipmitool sel list | grep -i ecc 
> > register: sel_out 
> > failed_when: sel_out.rc > 1 
> > async: 3 
> > poll: 2 
> > 
> > 
> > TASK [Check for ECC's] 
> > 
> **
>  
>
> > fatal: [192.168.100.11]: FAILED! => {"failed": true, "msg": "The 
> > conditional check 'sel_out.rc > 1' failed. The error was: error while 
> > evaluating conditional (sel_out.rc > 1): 'dict object' has no attribute 
> > 'rc'"} 
> This usually doesn't happen, I guess it's because of async and/or poll. 
> Why are you using them? Remove them and I guess it would work fine. 
>
>
> -- 
> Kai Stian Olstad 
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/329e71be-1bef-4819-b770-478513a88d9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Add conditionals to debug msg

2017-08-14 Thread Kai Stian Olstad

On 14. aug. 2017 23:58, Ryan wrote:

Thanks for the detailed reply.

  - name: Check for ECC's
shell: ipmitool sel list | grep -i ecc
register: sel_out
failed_when: sel_out.rc > 1
async: 3
poll: 2


TASK [Check for ECC's]
**
fatal: [192.168.100.11]: FAILED! => {"failed": true, "msg": "The
conditional check 'sel_out.rc > 1' failed. The error was: error while
evaluating conditional (sel_out.rc > 1): 'dict object' has no attribute
'rc'"}

This usually doesn't happen, I guess it's because of async and/or poll.
Why are you using them? Remove them and I guess it would work fine.


--
Kai Stian Olstad

--
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5ef13731-206c-f2b5-8878-45781aebc84b%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Add conditionals to debug msg

2017-08-14 Thread Ryan
Thanks for the detailed reply.

 - name: Check for ECC's
   shell: ipmitool sel list | grep -i ecc
   register: sel_out
   failed_when: sel_out.rc > 1
   async: 3
   poll: 2


TASK [Check for ECC's] 
**
fatal: [192.168.100.11]: FAILED! => {"failed": true, "msg": "The 
conditional check 'sel_out.rc > 1' failed. The error was: error while 
evaluating conditional (sel_out.rc > 1): 'dict object' has no attribute 
'rc'"}


On Saturday, August 12, 2017 at 1:43:10 AM UTC-7, Kai Stian Olstad wrote:
>
> On 12. aug. 2017 04:09, Ryan wrote: 
> > I tried adding "changed_when" for when sel_out is not defined, but it 
> gives 
> > me an error, so I am not sure how to use "changed_when" in this case. 
>
> I'm sorry, i meant to write failed_when and not changed_when, but the 
> usage is the same. 
>
>
> >   What's the correct usage? 
> > 
> >   - name: Check for ECC's 
> > shell: ipmitool sel list | grep -i ecc 
> > register: sel_out 
> > changed_when: sel_out is not defined 
> > async: 3 
> > poll: 2 
> > 
> > fatal: [192.168.100.11]: FAILED! => {"ansible_job_id": 
> > "186470565638.100676", "changed": false, "cmd": "ipmitool sel list | 
> grep 
> > -i ecc", "delta": "0:00:00.094723", "end": "2017-08-12 01:40:04.893313", 
> > "failed": true, "finished": 1, "rc": 1, "start": "2017-08-12 
> > 01:40:04.798590", "stderr": "", "stderr_lines": [], "stdout": "", 
> > "stdout_lines": []} 
>
> As you can see in you fatal output, the sel_out is defined. 
> rc (return code) is 1, failed = true and stdout is empty. 
>
> grep exit with 0 when it finds the string and 1 if it doesn't find the 
> string, so an error you can be defined as rc > 1. 
>
>- name: Check for ECC's 
>  shell: ipmitool sel list | grep -i ecc 
>  register: sel_out 
>  failed_when: sel_out.rc > 1 
>  async: 3 
>  poll: 2 
>
>
> > I was able to use this method, which seems to work.  Is this the correct 
> > usage of "|| true"? 
> > 
> >   - name: Check for ECC's 
> > shell: ipmitool sel list | grep -i ecc || true 
> > register: sel_out 
> > async: 3 
> > poll: 2 
>
> By using || true sel_out.rc will always be 0, so you loose the ability 
> to check what return code grep is giving. So i highly recommend the 
> solution above. 
>
>
> > With the above usage, I am back to my original question.  How can I add 
> > conditionals to individual items in a debug msg list? 
>
> Short answer, you can't. 
>
> when can only be used on debug it self, not the msg list. 
>
>
> >  For instance, how 
> > can I add a conditional only for "{{sel_out.stdout.split('\n') }}"?  If 
> i 
> > put the "when" in the same column as "name" and "debug" as Dick 
> suggested, 
> > then it will impact the full debug msg list, not only the sel_out line. 
>
> If the grep doesn't find anything the sel_out.stdout.split('\n') will be 
> a empty string. 
>
> If you don't want that you can split debug in several tasks and use 
> when: on the task. 
>
> or since you have 2 variables, this gives 4 combination, so you could 
> make 4 debug task with 4 different when's. 
>
>
> -- 
> Kai Stian Olstad 
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/83d3fa9f-589f-4d66-be35-0a5e2c2efc9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Add conditionals to debug msg

2017-08-12 Thread Kai Stian Olstad

On 12. aug. 2017 04:09, Ryan wrote:

I tried adding "changed_when" for when sel_out is not defined, but it gives
me an error, so I am not sure how to use "changed_when" in this case.


I'm sorry, i meant to write failed_when and not changed_when, but the 
usage is the same.




  What's the correct usage?

  - name: Check for ECC's
shell: ipmitool sel list | grep -i ecc
register: sel_out
changed_when: sel_out is not defined
async: 3
poll: 2

fatal: [192.168.100.11]: FAILED! => {"ansible_job_id":
"186470565638.100676", "changed": false, "cmd": "ipmitool sel list | grep
-i ecc", "delta": "0:00:00.094723", "end": "2017-08-12 01:40:04.893313",
"failed": true, "finished": 1, "rc": 1, "start": "2017-08-12
01:40:04.798590", "stderr": "", "stderr_lines": [], "stdout": "",
"stdout_lines": []}


As you can see in you fatal output, the sel_out is defined.
rc (return code) is 1, failed = true and stdout is empty.

grep exit with 0 when it finds the string and 1 if it doesn't find the 
string, so an error you can be defined as rc > 1.


  - name: Check for ECC's
shell: ipmitool sel list | grep -i ecc
register: sel_out
failed_when: sel_out.rc > 1
async: 3
poll: 2



I was able to use this method, which seems to work.  Is this the correct
usage of "|| true"?

  - name: Check for ECC's
shell: ipmitool sel list | grep -i ecc || true
register: sel_out
async: 3
poll: 2


By using || true sel_out.rc will always be 0, so you loose the ability 
to check what return code grep is giving. So i highly recommend the 
solution above.




With the above usage, I am back to my original question.  How can I add
conditionals to individual items in a debug msg list?


Short answer, you can't.

when can only be used on debug it self, not the msg list.



 For instance, how
can I add a conditional only for "{{sel_out.stdout.split('\n') }}"?  If i
put the "when" in the same column as "name" and "debug" as Dick suggested,
then it will impact the full debug msg list, not only the sel_out line.


If the grep doesn't find anything the sel_out.stdout.split('\n') will be 
a empty string.


If you don't want that you can split debug in several tasks and use 
when: on the task.


or since you have 2 variables, this gives 4 combination, so you could 
make 4 debug task with 4 different when's.



--
Kai Stian Olstad

--
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/42b0bc3d-7dad-5f91-939e-97c144ea8ab8%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Add conditionals to debug msg

2017-08-11 Thread Ryan
I tried adding "changed_when" for when sel_out is not defined, but it gives 
me an error, so I am not sure how to use "changed_when" in this case. 
 What's the correct usage?

 - name: Check for ECC's
   shell: ipmitool sel list | grep -i ecc
   register: sel_out
   changed_when: sel_out is not defined
   async: 3
   poll: 2

fatal: [192.168.100.11]: FAILED! => {"ansible_job_id": 
"186470565638.100676", "changed": false, "cmd": "ipmitool sel list | grep 
-i ecc", "delta": "0:00:00.094723", "end": "2017-08-12 01:40:04.893313", 
"failed": true, "finished": 1, "rc": 1, "start": "2017-08-12 
01:40:04.798590", "stderr": "", "stderr_lines": [], "stdout": "", 
"stdout_lines": []}


I was able to use this method, which seems to work.  Is this the correct 
usage of "|| true"?

 - name: Check for ECC's
   shell: ipmitool sel list | grep -i ecc || true
   register: sel_out
   async: 3
   poll: 2


With the above usage, I am back to my original question.  How can I add 
conditionals to individual items in a debug msg list?  For instance, how 
can I add a conditional only for "{{sel_out.stdout.split('\n') }}"?  If i 
put the "when" in the same column as "name" and "debug" as Dick suggested, 
then it will impact the full debug msg list, not only the sel_out line.

 - name: Print results
   debug:
msg:
   - "Board: {{ ansible_product_name }}"
   - "CPU: {{ ansible_processor[1] }}   Cores: {{ 
ansible_processor_cores }}   CPU Count: {{ ansible_processor_count }}"
   - "Memory: {{ ansible_memtotal_mb }}"
   - "ansible processor count: {{ ansible_processor_count }}"
   - "Log File: {{ logfile }}"
   - "{{ out.stdout.split('\n') }}"
   - "{{sel_out.stdout.split('\n') }}"



On Friday, August 11, 2017 at 2:51:29 AM UTC-7, Kai Stian Olstad wrote:
>
> On 11. aug. 2017 08:25, Ryan wrote: 
> > 
> > Sorry, I will attache the error next time. 
>
> But you didn't include all relevant output. 
>
>
> > I tried indenting it to the same column as name and debug, but it still 
> > failed.  If I change the command to something that returns a value for 
> > sel_out, the debug msg returns the expected output.  The error only 
> comes 
> > when sel_out is not defined. 
> > 
> > - name: Print results 
> > debug: 
> >   msg: 
> > - "Board: {{ ansible_product_name }}" 
> > - "CPU: {{ ansible_processor[1] }}   Cores: {{ 
> > ansible_processor_cores }}   CPU Count: {{ ansible_processor_count }}" 
> > - "Memory: {{ ansible_memtotal_mb }}" 
> > - "ansible processor count: {{ ansible_processor_count }}" 
> > - "Log File: {{ logfile }}" 
> > - "{{ out.stdout.split('\n') }}" 
> > - "{{sel_out.stdout.split('\n') }}" 
> > when: sel_out is defined 
> > 
> > 
> > fatal: [192.168.100.11]: FAILED! => {"ansible_job_id": 
> > "717909993947.50020", "changed": true, "cmd": "ipmitool sel list | grep 
> -i 
> > ecc", "delta": "0:00:00.088089", "end": "2017-08-11 06:02:57.289040", 
> > "failed": true, "finished": 1, "rc": 1, "start": "2017-08-11 
> > 06:02:57.200951", "stderr": "", "stderr_lines": [], "stdout": "", 
> > "stdout_lines": []} > 
>
> This error has noting to do with you debug task, it's the task you 
> running "ipmitool sel list" 
> Had you included more information about this error you would have seen 
> that easy a few lines before this statement. 
>
> grep isn't finding any ecc in the output av return code 1, this means 
> failure to ansible. 
> To change this you have can add "changed_when" to the task. 
>
>
> -- 
> Kai Stian Olstad 
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fca35767-8f48-45a9-a251-624dd07ea7df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Add conditionals to debug msg

2017-08-11 Thread Kai Stian Olstad

On 11. aug. 2017 08:25, Ryan wrote:


Sorry, I will attache the error next time.


But you didn't include all relevant output.



I tried indenting it to the same column as name and debug, but it still
failed.  If I change the command to something that returns a value for
sel_out, the debug msg returns the expected output.  The error only comes
when sel_out is not defined.

- name: Print results
debug:
  msg:
- "Board: {{ ansible_product_name }}"
- "CPU: {{ ansible_processor[1] }}   Cores: {{
ansible_processor_cores }}   CPU Count: {{ ansible_processor_count }}"
- "Memory: {{ ansible_memtotal_mb }}"
- "ansible processor count: {{ ansible_processor_count }}"
- "Log File: {{ logfile }}"
- "{{ out.stdout.split('\n') }}"
- "{{sel_out.stdout.split('\n') }}"
when: sel_out is defined


fatal: [192.168.100.11]: FAILED! => {"ansible_job_id":
"717909993947.50020", "changed": true, "cmd": "ipmitool sel list | grep -i
ecc", "delta": "0:00:00.088089", "end": "2017-08-11 06:02:57.289040",
"failed": true, "finished": 1, "rc": 1, "start": "2017-08-11
06:02:57.200951", "stderr": "", "stderr_lines": [], "stdout": "",
"stdout_lines": []} >


This error has noting to do with you debug task, it's the task you 
running "ipmitool sel list"
Had you included more information about this error you would have seen 
that easy a few lines before this statement.


grep isn't finding any ecc in the output av return code 1, this means 
failure to ansible.

To change this you have can add "changed_when" to the task.


--
Kai Stian Olstad

--
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/78385974-9deb-9c76-5d13-3e2d8c0334ab%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Add conditionals to debug msg

2017-08-10 Thread Ryan
There seems to be a paste formatting issue.  Under vim name and debug are 
in the same column.  They were not when I pasted them in the last reply.


On Thursday, August 10, 2017 at 11:25:52 PM UTC-7, Ryan wrote:
>
>
> Sorry, I will attache the error next time.
>
> I tried indenting it to the same column as name and debug, but it still 
> failed.  If I change the command to something that returns a value for 
> sel_out, the debug msg returns the expected output.  The error only comes 
> when sel_out is not defined.
>
> - name: Print results
>debug:
>  msg:
>- "Board: {{ ansible_product_name }}"
>- "CPU: {{ ansible_processor[1] }}   Cores: {{ 
> ansible_processor_cores }}   CPU Count: {{ ansible_processor_count }}"
>- "Memory: {{ ansible_memtotal_mb }}"
>- "ansible processor count: {{ ansible_processor_count }}"
>- "Log File: {{ logfile }}"
>- "{{ out.stdout.split('\n') }}"
>- "{{sel_out.stdout.split('\n') }}"
>when: sel_out is defined
>
>
> fatal: [192.168.100.11]: FAILED! => {"ansible_job_id": 
> "717909993947.50020", "changed": true, "cmd": "ipmitool sel list | grep -i 
> ecc", "delta": "0:00:00.088089", "end": "2017-08-11 06:02:57.289040", 
> "failed": true, "finished": 1, "rc": 1, "start": "2017-08-11 
> 06:02:57.200951", "stderr": "", "stderr_lines": [], "stdout": "", 
> "stdout_lines": []}
>
>
>
>
> On Thursday, August 10, 2017 at 10:32:55 PM UTC-7, Dick Visser wrote:
>>
>> Not sure what you mean by 'it doesn't like this method'? I'm guessing 
>> you're getting an error - which would have been helpful in diagnosing the 
>> issue.
>>
>> So again, guessing, and hard to see from this message, but it looks like 
>> the indentation of the when statement is way off. It should be at the same 
>> column as name and debug.
>>
>> Dick
>>
>> On Thu, 10 Aug 2017 at 22:55, Ryan  wrote:
>>
>>> How do I add a conditionals to debug msg lists?
>>>
>>>  - name: Print results
>>>debug:
>>>  msg:
>>>- "Board: {{ ansible_product_name }}"
>>>- "CPU: {{ ansible_processor[1] }}   Cores: {{ 
>>> ansible_processor_cores }}   CPU Count: {{ ansible_processor_count }}"
>>>- "Memory: {{ ansible_memtotal_mb }}"
>>>- "ansible processor count: {{ ansible_processor_count }}"
>>>- "Log File: {{ logfile }}"
>>>- "{{ out.stdout.split('\n') }}"
>>>- "{{sel_out.stdout.split('\n') }}"
>>>
>>>
>>> Depending on the results, sometimes "register: out" and/or "register: 
>>> sel_out" may not be defined, so the last two messages, will fail if not 
>>> defined.  I tried using the following, but it does not like this method, so 
>>> i am doing it wrong.
>>>
>>>  - name: Print results
>>>debug:
>>>  msg:
>>>- "Board: {{ ansible_product_name }}"
>>>- "CPU: {{ ansible_processor[1] }}   Cores: {{ 
>>> ansible_processor_cores }}   CPU Count: {{ ansible_processor_count }}"
>>>- "Memory: {{ ansible_memtotal_mb }}"
>>>- "ansible processor count: {{ ansible_processor_count }}"
>>>- "Log File: {{ logfile }}"
>>>- "{{ out.stdout.split('\n') }}"
>>>- "{{sel_out.stdout.split('\n') }}"
>>>when: sel_out is defined
>>>
>>>
>>> -- 
>>> 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.
>>> To post to this group, send email to ansible...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/ansible-project/9e896ba5-12df-4a8b-8cff-0dec822277bd%40googlegroups.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> -- 
>> Dick Visser
>> GÉANT
>>
>> Want to join us? We're hiring: https://www.geant.org/jobs
>>
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/46c59a3c-c15a-4b1c-b44d-f16a04fc0039%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Add conditionals to debug msg

2017-08-10 Thread Ryan

Sorry, I will attache the error next time.

I tried indenting it to the same column as name and debug, but it still 
failed.  If I change the command to something that returns a value for 
sel_out, the debug msg returns the expected output.  The error only comes 
when sel_out is not defined.

- name: Print results
   debug:
 msg:
   - "Board: {{ ansible_product_name }}"
   - "CPU: {{ ansible_processor[1] }}   Cores: {{ 
ansible_processor_cores }}   CPU Count: {{ ansible_processor_count }}"
   - "Memory: {{ ansible_memtotal_mb }}"
   - "ansible processor count: {{ ansible_processor_count }}"
   - "Log File: {{ logfile }}"
   - "{{ out.stdout.split('\n') }}"
   - "{{sel_out.stdout.split('\n') }}"
   when: sel_out is defined


fatal: [192.168.100.11]: FAILED! => {"ansible_job_id": 
"717909993947.50020", "changed": true, "cmd": "ipmitool sel list | grep -i 
ecc", "delta": "0:00:00.088089", "end": "2017-08-11 06:02:57.289040", 
"failed": true, "finished": 1, "rc": 1, "start": "2017-08-11 
06:02:57.200951", "stderr": "", "stderr_lines": [], "stdout": "", 
"stdout_lines": []}




On Thursday, August 10, 2017 at 10:32:55 PM UTC-7, Dick Visser wrote:
>
> Not sure what you mean by 'it doesn't like this method'? I'm guessing 
> you're getting an error - which would have been helpful in diagnosing the 
> issue.
>
> So again, guessing, and hard to see from this message, but it looks like 
> the indentation of the when statement is way off. It should be at the same 
> column as name and debug.
>
> Dick
>
> On Thu, 10 Aug 2017 at 22:55, Ryan > 
> wrote:
>
>> How do I add a conditionals to debug msg lists?
>>
>>  - name: Print results
>>debug:
>>  msg:
>>- "Board: {{ ansible_product_name }}"
>>- "CPU: {{ ansible_processor[1] }}   Cores: {{ 
>> ansible_processor_cores }}   CPU Count: {{ ansible_processor_count }}"
>>- "Memory: {{ ansible_memtotal_mb }}"
>>- "ansible processor count: {{ ansible_processor_count }}"
>>- "Log File: {{ logfile }}"
>>- "{{ out.stdout.split('\n') }}"
>>- "{{sel_out.stdout.split('\n') }}"
>>
>>
>> Depending on the results, sometimes "register: out" and/or "register: 
>> sel_out" may not be defined, so the last two messages, will fail if not 
>> defined.  I tried using the following, but it does not like this method, so 
>> i am doing it wrong.
>>
>>  - name: Print results
>>debug:
>>  msg:
>>- "Board: {{ ansible_product_name }}"
>>- "CPU: {{ ansible_processor[1] }}   Cores: {{ 
>> ansible_processor_cores }}   CPU Count: {{ ansible_processor_count }}"
>>- "Memory: {{ ansible_memtotal_mb }}"
>>- "ansible processor count: {{ ansible_processor_count }}"
>>- "Log File: {{ logfile }}"
>>- "{{ out.stdout.split('\n') }}"
>>- "{{sel_out.stdout.split('\n') }}"
>>when: sel_out is defined
>>
>>
>> -- 
>> 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 .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/9e896ba5-12df-4a8b-8cff-0dec822277bd%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> -- 
> Dick Visser
> GÉANT
>
> Want to join us? We're hiring: https://www.geant.org/jobs
>

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6c51d662-5d79-4be5-a6b7-f63c147c0063%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Add conditionals to debug msg

2017-08-10 Thread Dick Visser
Not sure what you mean by 'it doesn't like this method'? I'm guessing
you're getting an error - which would have been helpful in diagnosing the
issue.

So again, guessing, and hard to see from this message, but it looks like
the indentation of the when statement is way off. It should be at the same
column as name and debug.

Dick

On Thu, 10 Aug 2017 at 22:55, Ryan  wrote:

> How do I add a conditionals to debug msg lists?
>
>  - name: Print results
>debug:
>  msg:
>- "Board: {{ ansible_product_name }}"
>- "CPU: {{ ansible_processor[1] }}   Cores: {{
> ansible_processor_cores }}   CPU Count: {{ ansible_processor_count }}"
>- "Memory: {{ ansible_memtotal_mb }}"
>- "ansible processor count: {{ ansible_processor_count }}"
>- "Log File: {{ logfile }}"
>- "{{ out.stdout.split('\n') }}"
>- "{{sel_out.stdout.split('\n') }}"
>
>
> Depending on the results, sometimes "register: out" and/or "register:
> sel_out" may not be defined, so the last two messages, will fail if not
> defined.  I tried using the following, but it does not like this method, so
> i am doing it wrong.
>
>  - name: Print results
>debug:
>  msg:
>- "Board: {{ ansible_product_name }}"
>- "CPU: {{ ansible_processor[1] }}   Cores: {{
> ansible_processor_cores }}   CPU Count: {{ ansible_processor_count }}"
>- "Memory: {{ ansible_memtotal_mb }}"
>- "ansible processor count: {{ ansible_processor_count }}"
>- "Log File: {{ logfile }}"
>- "{{ out.stdout.split('\n') }}"
>- "{{sel_out.stdout.split('\n') }}"
>when: sel_out is defined
>
>
> --
> 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 post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/9e896ba5-12df-4a8b-8cff-0dec822277bd%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 
Dick Visser
GÉANT

Want to join us? We're hiring: https://www.geant.org/jobs

-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwMoRdGObnXZQmgMNBh18eKqzBaMBrZiKL06H9eE7ymY6A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Add conditionals to debug msg

2017-08-10 Thread Ryan
How do I add a conditionals to debug msg lists?

 - name: Print results
   debug:
 msg:
   - "Board: {{ ansible_product_name }}"
   - "CPU: {{ ansible_processor[1] }}   Cores: {{ 
ansible_processor_cores }}   CPU Count: {{ ansible_processor_count }}"
   - "Memory: {{ ansible_memtotal_mb }}"
   - "ansible processor count: {{ ansible_processor_count }}"
   - "Log File: {{ logfile }}"
   - "{{ out.stdout.split('\n') }}"
   - "{{sel_out.stdout.split('\n') }}"


Depending on the results, sometimes "register: out" and/or "register: 
sel_out" may not be defined, so the last two messages, will fail if not 
defined.  I tried using the following, but it does not like this method, so 
i am doing it wrong.

 - name: Print results
   debug:
 msg:
   - "Board: {{ ansible_product_name }}"
   - "CPU: {{ ansible_processor[1] }}   Cores: {{ 
ansible_processor_cores }}   CPU Count: {{ ansible_processor_count }}"
   - "Memory: {{ ansible_memtotal_mb }}"
   - "ansible processor count: {{ ansible_processor_count }}"
   - "Log File: {{ logfile }}"
   - "{{ out.stdout.split('\n') }}"
   - "{{sel_out.stdout.split('\n') }}"
   when: sel_out is defined


-- 
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 post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/9e896ba5-12df-4a8b-8cff-0dec822277bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.