[ansible-project] Integer comparision issue in jinja2 template Ansible

2020-03-26 Thread Shifa Shaikh
My jinja2 template yields correct value for the variable {{ vars[allip.name | join("")] | default('ERR') }} The variable has value 82.3 which gets printed by Ansible's template module. I wish to write an if condition where I want to check if the value of the variable is more than 80 {% if (

[ansible-project] Downloading files with a specific regular expression from remote https host to target server local path.

2020-03-26 Thread Tom K.
Having some difficulty finding what is the Ansible code to do this: Downloading files with a specific regular expression from remote http / https host to a target server local path. So would like to wget http://remote.com/rpm/app*.rpm to a set of target servers. get_url doesn't appear to

Re: [ansible-project] How to extract a value of a field within a list of dictionaries when a key matches another value

2020-03-26 Thread jean-christophe manciot
I also tried that one but it also fails: - name: test with json_query 1/2 vars: - domain_definition: - name: server11 cluster: cluster1 port: '8080' - name: server12 cluster: cluster2

[ansible-project] How to extract a value of a field within a list of dictionaries when a key matches another value

2020-03-26 Thread jean-christophe manciot
Let’s suppose the following data structure: - domain_definition: - name: server11 cluster: cluster1 port: '8080' - name: server12 cluster: cluster2 port: '8090' - name:

Re: [ansible-project] How to extract a value of a field within a list of dictionaries when a key matches another value

2020-03-26 Thread Vladimir Botka
On Thu, 26 Mar 2020 11:43:33 -0700 (PDT) jean-christophe manciot wrote: > Let’s suppose the following data structure: > - domain_definition: > - name: server11 > cluster: cluster1 > port: '8080' > - name: server12 >

Re: [ansible-project] How to extract a value of a field within a list of dictionaries when a key matches another value

2020-03-26 Thread Vladimir Botka
On Thu, 26 Mar 2020 20:02:47 +0100 Vladimir Botka wrote: > > The playbook below > > - name: test with json_query 1/2 > hosts: localhost > vars: > domain_definition: > - name: server11 > cluster: cluster1 > port: '8080' > - name: server12 > cluster:

[ansible-project] Integer comparison if condition jinja2 template Ansible does not work

2020-03-26 Thread Shifa Shaikh
My jinja2 template yields correct value for the variable {{ vars[allip.name | join("")] | default('ERR') }} The variable has value 82.3 which gets printed by Ansible's template module. I wish to write an if condition where I want to check if the value of the variable is more than 80 {% if (

Re: [ansible-project] How to extract a value of a field within a list of dictionaries when a key matches another value

2020-03-26 Thread Dick Visser
What Vladimir said (twice): You are using: debug: var: while you should be doing: debug: msg: Dick On Thu, 26 Mar 2020 at 20:19, jean-christophe manciot wrote: > > Same result with your second proposal. > > -- > You received this message because you are subscribed to the Google Groups

Re: [ansible-project] Downloading files with a specific regular expression from remote https host to target server local path.

2020-03-26 Thread Dick Visser
It's fundamentally impossible to do what you want, unless the remote server offers some sort of file system equivalent, like a directory index. Dick On Thu, 26 Mar 2020 at 19:24, Tom K. wrote: > > Having some difficulty finding what is the Ansible code to do this: > > Downloading files with a

Re: [ansible-project] How to extract a value of a field within a list of dictionaries when a key matches another value

2020-03-26 Thread jean-christophe manciot
Same result with your second proposal. -- 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

Re: [ansible-project] Unable to get correct disk space utilized percentage using Ansible API

2020-03-26 Thread Shifa Shaikh
Thank you @Kai for the excellent explanation :) On Thursday, March 26, 2020 at 12:41:00 AM UTC+5:30, Kai Stian Olstad wrote: > > On Wed, Mar 25, 2020 at 09:54:07AM -0700, Shifa Shaikh wrote: > > @Kia Hi, > > > > As suggested I tried > > > > item.size_total instead of item.size_available > >

[ansible-project] ternary clarification needed

2020-03-26 Thread Davide Scrimieri
Hello, Whenever a ternary is used are both conditions evaluated regardless ? For example, I want to convert "my_other_var" to an object only if it is passed as as string, otherwise I don't want to touch the object, and leave it as it is. - set_fact: my_var: "{{ ( my_other_var |

RE: [ansible-project] Re: Create AWS EFS

2020-03-26 Thread sandy.hung
EFS tags is error? - hosts: localhost > >connection: local > >gather_facts: no > > > >vars_files: > > - ec2key.yml > > > >tasks: > > > >- name: Create EFS > >

Re: [ansible-project] Re: ternary clarification needed

2020-03-26 Thread Karl Auer
> Whenever a ternary is used are both conditions evaluated regardless ? A ternary filter consists of three parts: a) the condition b) the statement to be evaluated if the condition is true c) the statement to be evaluted if the condition is false. Only one of b) and c) will be evaluated, but

Re: [ansible-project] ternary clarification needed

2020-03-26 Thread Davide Scrimieri
Thank you all for the answers. I used the solution "from_yaml" provided by Vladimir and it works like a charm, and it's also cleaner. However, if this is the case, I don't believe this is an issue of how ternary works, but of how "from_json" works. My gut feeling is that it shouldn't behave that

Re: [ansible-project] Unable to get remote target hostname when using delegate_to

2020-03-26 Thread Kai Stian Olstad
On Wed, Mar 25, 2020 at 10:41:35PM -0700, Shifa Shaikh wrote: > --- > hosts: remote_hosts > tasks: > - name: Generate JSON data > lineinfile: > path: "{{ playbook_dir }}/tmpfiles/stats.yml" > line: "{{ inventory_hostname }}_{{ item.mount }}: {{ (100 * >

Re: [ansible-project] ternary clarification needed

2020-03-26 Thread Vladimir Botka
On Wed, 25 Mar 2020 23:54:57 -0700 (PDT) Davide Scrimieri wrote: > I want to convert "my_other_var" to an object only if it is > passed as as string, otherwise I don't want to touch the object, and leave > it as it is. > > - set_fact: > my_var: "{{ ( my_other_var | type_debug == 'str' )

[ansible-project] Re: ansible windows inventory get hostname/user/password ad-hoc from external script

2020-03-26 Thread 'J Hawkesworth' via Ansible Project
Would constructing your own lookup plugin be an option? There seem to be lots of lookup plugins that look things up in various kinds of vaults: https://docs.ansible.com/ansible/latest/plugins/lookup.html#plugin-list Could you create one of your own. If you created an inventory plugin, rather

Re: [ansible-project] ternary clarification needed

2020-03-26 Thread Martin Krizek
On Thu, Mar 26, 2020 at 7:55 AM Davide Scrimieri wrote: > > Hello, > > Whenever a ternary is used are both conditions evaluated regardless ? > > For example, I want to convert "my_other_var" to an object only if it is > passed as as string, otherwise I don't want to touch the object, and leave

[ansible-project] Re: ternary clarification needed

2020-03-26 Thread Davide Scrimieri
UPDATE: PLEASE, DISCARD what I said about the when statement at the end of my post, in my original code I had a typo, and was not working for other reasons. The first part of the post about the ternary statement still stands On Thursday, March 26, 2020 at 7:54:58 AM UTC+1, Davide Scrimieri

[ansible-project] Problems with gcp_compute_instance

2020-03-26 Thread Thomas Kube
Hello, I'm branching to a problem with gcp_compute_instance. The server should be created inside a project that has a shared subnet in custom mode. These are the individual steps to gather the informations for the network: - name: "Gather network information for {{ vpc_project }}"

[ansible-project] Re: Problems with gcp_compute_instance

2020-03-26 Thread Thomas Kube
If I specify only the subnetwork value, then the server is assigned an IP address: network_interfaces: - subnetwork: "{{ selfLink }}" Thomas -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and

[ansible-project] Re: Problems with gcp_compute_instance

2020-03-26 Thread Thomas Kube
Sorry, found it: network_interfaces: - network_ip: "{{ ipaddress.address }}" - subnetwork: "{{ selfLink }}" is wrong network_interfaces: - subnetwork: "{{ selfLink }}" network_ip: "{{ ipaddress.address }}" is right. My fault. Thomas -- You received this