Re: [ansible-project] Re: Variable disappears...

2018-05-08 Thread David Villasmil
Hello Jordan, That's exactly my problem! Now i understand why it's not on the second play. I get the variable again on the second play and it's working properly. Thanks a lot for the exaplanation! David On Tue, May 8, 2018, 22:00 Jordan Borean wrote: > Without seeing the

[ansible-project] Re: Variable disappears...

2018-05-08 Thread David Villasmil
It's confirmed, if you set a variable on a playbook, and add_host and make new tasks, this variable is not "forwarded" to the next tasks On Tuesday, May 8, 2018 at 5:04:03 PM UTC+2, David Villasmil wrote: > > Hello all, > > I've got a playbook that does: > > - n

[ansible-project] terminating instances

2018-05-10 Thread David Villasmil
hello all, I run "ec2_instance_facts" to get some instance_ids: - ec2_instance_facts: region: us-east-1 filters: "tag:Name": "*{{ cluster }}*" register: ec2_res Then i can properly print the instance_ids only for those running: - name: print ips debug: "msg={{ item.instance_id }}" with_items:

Re: [ansible-project] creating new dictionary from existing dictionary

2018-05-12 Thread David Villasmil
Try with var: "{{ var + item.pass }}" Cheers On Sat, May 12, 2018, 17:36 Ali Khawaja wrote: > Hi Everyone, > > > > I am trying to read a dict from a file (list of user ids), and create > another dict with key/value pairs (user ids with passwords). But once my > script

[ansible-project] Re: terminating instances

2018-05-11 Thread David Villasmil
Anyone able to help? On Thursday, May 10, 2018 at 11:27:06 PM UTC+2, David Villasmil wrote: > > hello all, > > I run "ec2_instance_facts" to get some instance_ids: > > - ec2_instance_facts: > region: us-east-1 > filters: > "tag:Name": "*

Re: [ansible-project] Re: terminating instances

2018-05-11 Thread David Villasmil
ndented at the same level as ec2 task similar to the debug task > > > On Thursday, May 10, 2018 at 2:27:06 PM UTC-7, David Villasmil wrote: >> >> hello all, >> >> I run "ec2_instance_facts" to get some instance_ids: >> >> - ec2_instance_facts:

[ansible-project] Variable disappears...

2018-05-08 Thread David Villasmil
Hello all, I've got a playbook that does: - name: Get db cluster endpoint shell: "aws --region=us-east-1 rds describe-db-clusters --db-cluster-identifier {{ cluster }}-kam-db" register: aws_cluster_res - set_fact: myvar: "{{ aws_cluster_res.stdout | from_json }}" - set_fact: endpoint: "{{

[ansible-project] Re: Variable disappears...

2018-05-08 Thread David Villasmil
Thanks for replying: $ ansible-playbook --version ansible-playbook 2.5.2 config file = /etc/ansible/ansible.cfg configured module search path = [u'/home/admin/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location =

Re: [ansible-project] Re: Variable disappears...

2018-05-08 Thread David Villasmil
d and the "replace" task > to see when it starts to "disappears" > > On Tuesday, May 8, 2018 at 8:04:03 AM UTC-7, David Villasmil wrote: >> >> Hello all, >> >> I've got a playbook that does: >> >> - name: Get db cluster endpoint >&g

[ansible-project] Extracting data from ec2 output

2018-05-07 Thread David Villasmil
hello all, After executing ec2 create, with "with_sequence", i need to retrieve each instance's "id", "dns_name" and "tags"->"Name". the response is as follows: <127.0.0.1> EXEC /bin/sh -c 'rm -f -r /home/admin/.ansible/tmp/ansible-tmp-1525715943.61-189658929132615/ > /dev/null 2>&1 && sleep

Re: [ansible-project] Ansible looping over register and multiple lists

2018-05-21 Thread David Villasmil
Please paste the code WITHOUT any formatting. Font should be any single-space so that spacing is correct. On Mon, May 21, 2018, 15:55 Jeremie Levy wrote: > Hi > I'm trying to do the following (in windows but it's not important): > > >1. Need to deploy N number of build

Re: [ansible-project] Need help to find how to run root command with non-root user and escalated privilages

2018-05-21 Thread David Villasmil
I think if you set 'become' then you don't need to use sudo. Also, why don't you use the module to install packages instead of executing yum? http://docs.ansible.com/ansible/latest/modules/yum_module.html Example: - name: install one specific version of Apache yum: name:

[ansible-project] Re: Nested variable

2018-05-23 Thread David Villasmil
Solved! - set_fact: hosted_zone_id: "{{ dns_results | json_query('HostedZones[?Name==`(lookup('vars', hosted_zone_name)).`].[Id]') | regex_replace ('/hostedzone/', '') }}" For future reference. Thanks David On Wednesday, May 23, 2018 at 10:04:16 PM UTC+2, David Villa

[ansible-project] Nested variable

2018-05-23 Thread David Villasmil
Hello guys, I've got this set_fact: hosted_zone_id: "{{ dns_results | json_query('HostedZones[?Name==`mydomain.com.`].[Id]') | regex_replace ('/hostedzone/', '') }}" But i want to get the id from any of my domains, so i want to use a variable: hosted_zone_name: "mydomain.com" and do

[ansible-project] Re: route53 alias_hosted_zone_id

2018-05-23 Thread David Villasmil
Nevermind, layer 8.. my mistake, i will open a new one On Wednesday, May 23, 2018 at 8:39:24 PM UTC+2, David Villasmil wrote: > > Hello guys, > > I can use like: > > # >> Create the DNS load balancer to the instances > - name: Creating DNS load balancer > ro

[ansible-project] Re: Nested variable

2018-05-23 Thread David Villasmil
Spoke too soon... That doesn't work either... On Wednesday, May 23, 2018 at 10:04:16 PM UTC+2, David Villasmil wrote: > > Hello guys, > > > I've got this set_fact: > > hosted_zone_id: "{{ dns_results | > json_query('HostedZones[?Name==`mydomain.com.`].[Id]') | r

[ansible-project] lookup not working

2018-05-23 Thread David Villasmil
Hello guys, i'm trying to use a variable inside a variable. https://pastebin.com/QmRX3jmz lookup SHUOLD work but it doesn't... can anyone help? -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop

[ansible-project] lookup not working

2018-05-23 Thread David Villasmil
Hello guys, i'm trying to use a variable inside a variable. https://pastebin.com/bu5BuM4y lookup SHUOLD work but it doesn't... can anyone help? -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop

[ansible-project] concatenate multiple results

2018-05-25 Thread David Villasmil
Hellos guys, I have a result from ec2_instance_facts, and i can get the ip addresses like: - name: Get IP addresses from results set_fact: inject_ips: “{{ facts_output | json_query(‘instances[]. public_ip_address’) }}” and that gives me something like: ok: [localhost] => {

[ansible-project] Re: Nested variable

2018-05-24 Thread David Villasmil
Hey Jordan, Thanks for replying! There were "`" missing, worked beautifully after that! - set_fact: hosted_zone_id: "{{ dns_results | json_query('HostedZones[?Name==`' ~ hosted_zone_name ~ '.`].[Id]') | regex_replace('/hostedzone/', '') }}" "~" escapes it, so there's no need to do a

[ansible-project] How to set environment dynamically

2018-05-24 Thread David Villasmil
Hello Guys, So, i have a vars file with something like this: --- aws_740: AWS_ACCESS_KEY_ID: "MY_KEY" AWS_SECRET_ACCESS_KEY: "MY_SECRET" AWS_DEFAULT_REGION: us-east-1 aws_756: AWS_ACCESS_KEY_ID: "MY_KEY" AWS_SECRET_ACCESS_KEY: "MY_SECRET" AWS_DEFAULT_REGION: us-east-1 And I want

[ansible-project] route53 alias_hosted_zone_id

2018-05-23 Thread David Villasmil
Hello guys, I can use like: # >> Create the DNS load balancer to the instances - name: Creating DNS load balancer route53: command: create zone: "{{ domain }}" value: "{{ cluster }}-{{ item }}.{{ domain }}" alias: true alias_hosted_zone_id: "KLAIUDIAUHSINUD"

Re: [ansible-project] Setting windows host/machine name using ansible

2018-05-27 Thread David Villasmil
You can use ec2_tags. On Sun, May 27, 2018, 13:16 Ali Khawaja wrote: > Hi, > > is there a way in ansible to set the name of the windows host when we are > creating the ec2 instance or maybe change it afterwards? > > Thanks > Ali > > -- > You received this message because you

Re: [ansible-project] Re: ec2 creation vs ec2 retreival: different value of registered variable

2018-05-27 Thread David Villasmil
Remove all formatting please On Sun, May 27, 2018, 11:28 wrote: > what i have realized is that on ec2 retrieval, the output is a json > object, whereas on ec2 creation, the output is json but in a string > format. is this understanding correct? do i need to convert the