[ansible-project] Re: [WARNING]: when statements should not include jinja2 templating delimiters such as {{ }} or {% %}.

2017-06-30 Thread trg . achilles
Josh, thank you for the hint. Work as expected. -- 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

[ansible-project] Using json query filter

2017-06-30 Thread trg . achilles
Hello, I'm trying to determined if package is installed and what version I have the following tasks vars: cmk_version: 1.4.0p7 - name: Check if check-mk-raw package is installed yum: list: installed register: yum_packages - name: Display cmk_installed_version

[ansible-project] Re: Using json query filter

2017-06-30 Thread 'J Hawkesworth' via Ansible Project
I can recommend using the http://jmespath.org/tutorial.html to figure out what your jsonquery needs to be. You can paste your json into any of the example boxes and then tinker with the jsonquery and see the results directly on the webpage. Hope this helps a bit Jon On Friday, June 30, 2017

Re: [ansible-project] Multiple and/or conditions in when wont work

2017-06-30 Thread Brian Coca
Multiple AND/OR do work, are you sure your conditions are being met? -- Brian Coca -- 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+uns

[ansible-project] Error assigning variables with Conditionals

2017-06-30 Thread Josu Vilda
When assigning variables under certain conditions, if there is no match, the last condition is erroneously assigned. Ej: --- - hosts: hostwin vars: # Definimos el paquete a instalar según el sistema operativo. - package_name: httpd when: ansible_os_family == "Red Hat" - p

Re: [ansible-project] Error assigning variables with Conditionals

2017-06-30 Thread Brian Coca
Well, works as expected ... `when:` is a TASK keyword, not for use in var declarations, you need to use jinja2 expressions for conditionals like that: package_name: "{{ (ansible_os_family == "Red Hat")|ternary('httpd', 'apache2') }} -- Brian Coca -- You received this message because yo

[ansible-project] Re: Error assigning variables with Conditionals

2017-06-30 Thread Josu Vilda
ansible 2.2.1.0 Linux 2.6.32-504.el6.x86_64 #1 SMP Tue Sep 16 01:56:35 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux El viernes, 30 de junio de 2017, 14:24:13 (UTC+2), Josu Vilda escribió: When assigning variables under certain conditions, if there is no match, > the last condition is erroneously a

[ansible-project] Counting changes in looping tasks

2017-06-30 Thread Cev Ing
We do user management with Ansible. A few minutes ago I was a bit irritated by the summary Ansible generates. Although I added 15 users to a system, Ansible showed me in the summary only 1 change. The reason is, that the users are created in a loop and the loop counts only as one task. Is it po

[ansible-project] Re: Error assigning variables with Conditionals

2017-06-30 Thread Josu Vilda
Ok, This would be the right way, right? --- - hosts: hostwin vars: # definimos variables de ejemplo - site: localhost tasks: - name: Definimos variables para Red Hat. set_fact: package_name: "httpd" when: ansible_os_family == "Red Hat"

Re: [ansible-project] Re: Error assigning variables with Conditionals

2017-06-30 Thread Brian Coca
One way, I prefer to avoid 'right' and 'wrong'. -- Brian Coca -- 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...@googlegrou

Re: [ansible-project] local_actions: copy contents from stdout issue...LARGE file?

2017-06-30 Thread Jon Williams
Thanks...Whilst it does support those protocols, we cannot use those due to being unable to do password-less logins via SSH keys. Also, we can only connect to these devices on those protocols - we cannot go outbound from these devices to other servers. I have managed to script this in raw ansi

[ansible-project] How can i load a vars file in inventory which "prepares" a large number of variables via jinja2 expressions ?

2017-06-30 Thread ishan jain
For some servers in an inventory, i assign a range of ports. I want to use these ports in my playbooks while keeping them portable and compatible with any configuration. I am thinking of using variable for ports whose values are resolved via some script in inventory. Something like this: --In P

[ansible-project] Re: How can i load a vars file in inventory which "prepares" a large number of variables via jinja2 expressions ?

2017-06-30 Thread Cev Ing
I do something similar in a role by generating a YML file, which gets included later on by include_vars. This are the includes in the main.yml of the role: - include: generate_vars.yml - include_vars: generated_vars.yml And this is the task in generate_vars.yml: shell: |- exec >generated_var

[ansible-project] Reload certificates?

2017-06-30 Thread Dennis Benzinger | SAP Hybris
Hello Group, one of my roles is using get_url to download a file from a server whose certificate is not trusted out of the box. Therefore, in an earlier step, I install the necessary CA certificates. This works fine for newly started processes, for example. with "command: /usr/bin/curl" but Ansi

Re: [ansible-project] Multiple and/or conditions in when wont work

2017-06-30 Thread ajay jiwanand
I want the task to run if the os if redhat (this conditional works fine) and when either of the following extended vars are set security/specified_packages/kernel. On Friday, June 30, 2017 at 2:17:29 AM UTC-4, Kai Stian Olstad wrote: > > On 29. juni 2017 23:00, ajay jiwanand wrote: > > I am ha

[ansible-project] Re: How to reformat a yaml dictionary?

2017-06-30 Thread 'J Hawkesworth' via Ansible Project
I'm still bugged I can't figure this out. I can make a list of all components easily enough too - name: make a list of the components set_fact: components: "{{ components|default([]) |union( item.value) }}" with_dict: "{{ components_by_group }}" I haven't figured a

Re: [ansible-project] Multiple and/or conditions in when wont work

2017-06-30 Thread ajay jiwanand
i want to run the task when ansible_os_family == "RedHat" (this works) AND if none of the following variables are set (security,kernel,specified_packages) through extended variables (-e) On Friday, June 30, 2017 at 2:17:29 AM UTC-4, Kai Stian Olstad wrote: > > On 29. juni 2017 23:00, ajay jiwana

[ansible-project] Re: Multiple and/or conditions in when wont work

2017-06-30 Thread ajay jiwanand
Im posting my stack overflow question as it is much more clear: Ask Question up vote0down votefavorite I am having issues when tryi

Re: [ansible-project] Re: Multiple and/or conditions in when wont work

2017-06-30 Thread Kai Stian Olstad
On 30. juni 2017 19:10, ajay jiwanand wrote: Im posting my stack overflow question as it is much more clear: Ask Question up vote0down votefavorite

Re: [ansible-project] clear_host_errors bug?

2017-06-30 Thread Kai Stian Olstad
On 29. juni 2017 12:08, MKPhil wrote: I'm running Ansible 2.3.1.0 and getting some off behaviour with clear_host_errors - is this a bug??? Here's a sample Playbook: --- - name: Check Servers gather_facts: false hosts: windows tasks: - name: Check server with win_ping win_pi

Re: [ansible-project] Ansible variable with find

2017-06-30 Thread Anfield
Thanks! But how does it differentiate between just the text user, and the actual variable user? Or does it just know because user is defined as a variable at the top in the vars section? I tried that out and it works well. > -- You received this message because you are subscribed to the Goog

Re: [ansible-project] Ansible variable with find

2017-06-30 Thread Kai Stian Olstad
On 30. juni 2017 21:03, Anfield wrote: Thanks! But how does it differentiate between just the text user, and the actual variable user? Or does it just know because user is defined as a variable at the top in the vars section? Text is indicated with single or double quote, so 'user' or "user". W

[ansible-project] Re: Multiple and/or conditions in when wont work

2017-06-30 Thread Daniel JD
You could use the intersect filter from jinja2. I am thinking about sth. like the following: when: ansible_os_family == "RedHat" and not vars.keys() | intersect([security,kernel,specified_packages]) Am Donnerstag, 29. Juni 2017 23:34:16 UTC+2 schrieb ajay jiwanand: > > I am having issues with u

[ansible-project] Re: Permissions issue, cannot become root

2017-06-30 Thread Daniel JD
To install packages you need to be root. So set become_user to root. Now you need to give ansible your sudo password via "-K". You dont need the become_method or become_flags Am Mittwoch, 28. Juni 2017 10:49:28 UTC+2 schrieb lask001: > > Been banging my head against this since yesterday, hoping

[ansible-project] Re: Using json query filter

2017-06-30 Thread Daniel JD
Why not something like: - name: Check if check_mk is installed shell: 'yum list installed check-mk-raw-*' register: cmk_status - name: Check result debug: msg: "{{ cmk_status| ternary( cmk_status.stdout.[extract version here], "Not installed") }}" But the whole process that you wa

[ansible-project] Re: Using json query filter

2017-06-30 Thread Daniel JD
Why not something like: - name: Check if check_mk is installed shell: 'yum list installed check-mk-raw-*' register: cmk_status - name: Check result debug: msg: "{{ cmk_status| ternary( cmk_status.stdout.[extract version here], "Not installed") }}" Am Freitag, 30. Juni 2017 12:47:4

Re: [ansible-project] Re: Multiple and/or conditions in when wont work

2017-06-30 Thread ajay jiwanand
My bad I was working with many different solutions and combinations so I got confused. I tried tons of complicated ways .. can't believe such a simple one worked lol. I probably over complicated it but what you suggested works great! when: not (security is defined or kernel is defined or spec

[ansible-project] Re: Multiple and/or conditions in when wont work

2017-06-30 Thread ajay jiwanand
This doesn't work as if I put the second value (in this case kernel) it tries to check it throws an error saying security is undefined. I found that jinja2 templates dont seem to work in the when clause. I tried many jinja2 templates that should work in regular situations but they failed (e.g w