[ansible-project] Re: Nested loops with subelements

2014-11-04 Thread Ananda Debnath
I guess I could express it as a nested dict in the first place? ec2_specs: - { region: "us-east-1", ami: "ami-b66ed3de", count: 1, type: "t2.micro", containers: [{ name: "NGINX_A", hostport: "443" }, { name: "NGINX_B", hostport: "444" }] } - etc I suspect though that if I need to express a

[ansible-project] Nested loops with subelements

2014-11-04 Thread Ananda Debnath
Hi, As others have before me, I find the syntax for nested loops somewhat confusing :( Consider my group_vars: ec2_specs: - { region: "us-east-1", ami: "ami-b66ed3de", count: 1, type: "t2.micro" } - { region: "us-west-1", ami: "ami-b56e64f0", count: 2, type: "t2.micro" } - { region: "sa-ea

Re: [ansible-project] Finding out what groups a host is a member of in a template?

2014-11-04 Thread Matt Martz
The group_names variable will hold that info. It is a list of all groups that the current host is a member of. On Tuesday, November 4, 2014, Kevin Burton wrote: > For the life of me I can't seem to find this in the docs but I'm sure it's > possible. > > I have a template and I want to expand a s

[ansible-project] Finding out what groups a host is a member of in a template?

2014-11-04 Thread Kevin Burton
For the life of me I can't seem to find this in the docs but I'm sure it's possible. I have a template and I want to expand a string to all the groups that host is a member of. I'm using them as tags in our monitoring system. -- You received this message because you are subscribed to the Goo

Re: [ansible-project] Need help with error: msg: parameters are mutually exclusive: ['package', 'upgrade', 'deb']

2014-11-04 Thread Brian Coca
what you want is: apt: name={{ item.pkg }} state=latest upgrade is not for single packages but for upgrading all packages. On Tue, Nov 4, 2014 at 4:08 PM, Ayush Sharma wrote: > I'm using the following task to install a few utilities: > > `- name: install utilities > apt: name={{ item.pkg }

Re: [ansible-project] Re: Managing Primary/Secondary relationship in cluster

2014-11-04 Thread shirou
Another way is 'differenct'. (see http://docs.ansible.com/playbooks_variables.html#set-theory-filters) - debug: msg="{{ (groups['pair'] | difference(inventory_hostname))[0] }}" The result is list, not a value. So it requires [0] to get actual hostname. It works if there are more hosts. 2014

[ansible-project] jumphost sudo su AND remote sudo su

2014-11-04 Thread Phil Taylor
Hi everyone, I'm new here and to ansible so please be gentle ;-) I have a situation where to access the remote ansible host/s via SSH I need to: 1. have my public key on the jumphost as my user acct (A) 2. sudo su on jumphost to another account (B) 3. ssh to the remote as (B) using anot

[ansible-project] Need help with error: msg: parameters are mutually exclusive: ['package', 'upgrade', 'deb']

2014-11-04 Thread Ayush Sharma
I'm using the following task to install a few utilities: `- name: install utilities apt: name={{ item.pkg }} state=present upgrade=full with_items: - pkg: 'htop' - pkg: 'mytop' - pkg: 'iotop' - pkg: 'pv'` `When executing in check mode, I get the following error: fa

[ansible-project] Is there a reason for forcing verbose directory structure inside roles?

2014-11-04 Thread Teemu Kurppa
Hi, continuing discussion from Twitter: https://twitter.com/Teemu/status/529356262862241792 Is there a reason for forcing verbose directory structure inside roles? When making roles for internal purposes, I often start with a playbook and after it grows more complex I move a part of the functi

[ansible-project] copy module with hard link destination

2014-11-04 Thread Sean McGowan
Background: I am using Ansible 1.5 on RedHat. Apparently system-config-network creates a hard link to /etc/hosts and /etc/resolve.conf. I want to be able to copy the correct hosts file in place if is not there, whether or not the file links is > 1. What happens: If the source file is alread

[ansible-project] EC2 provisionning and configuring with variables from inventory/ec2.py

2014-11-04 Thread Olivier Vernin
Hi, I am facing a little problem and I don't find a clear solution I need to provision a new EC2 (AWS) instance and configure it. During the configuration I use some variables from the inventory script ec2.py So I tried two approaches: 1) I executed two different playbooks under a shell scri

[ansible-project] possible to use boto and ec2.py to return instance IDs instead of IP addresses?

2014-11-04 Thread Paul Stivers
$ ansible --version ansible 1.8 (develop 0179c13e04) last updated 2014/10/24 11:53:25 (GMT -700) Right now I'm using "-i inventories/ec2.py -l 'tag_Environment_" to apply playbooks to servers in an environment, by IP address. Now I have playbooks to stop and start all instances in an

Re: [ansible-project] Error in play using 'lineinfile' module

2014-11-04 Thread Willard Dennis
OK, I found the answer (yay RTFM!) in http://docs.ansible.com/playbooks_variables.html#other-useful-filters Working play is: - name: RHELFAM | Restrict SSH on Docker hosts to specific group members lineinfile: dest=/etc/ssh/sshd_config state=present regexp='^AllowGroups' line='Allo

Re: [ansible-project] playbook conditional include another playbook not wokring

2014-11-04 Thread jack
ansible 1.5.5 on Mac. -- 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 ansi

[ansible-project] Re: Managing Primary/Secondary relationship in cluster

2014-11-04 Thread Barry Morrison
I had the remnants of the aliases so host_vars/server1 didn't match 'primary' I'm not getting the var. Thanks! On Tuesday, November 4, 2014 2:17:34 PM UTC-8, James Martin wrote: > > Ah, I didn't see that last line. Do a: > > - debug: var=partner > > Just to make sure you have your variables l

Re: [ansible-project] Problem setting variable with bond0.11 IPv4 address from the gathered facts.

2014-11-04 Thread Joel Sdc
Hi Matt, Would this be valid? "{{ hostvars[{{ ansible_host }}]['ansible_bond0.11']['ipv4']['address'] }}" This is the playbook: --- - name: Setup SNMP on testservers hosts: testservers roles: - { role: snmp, snmp_rocommunity: comtestsrv, snmp_listen_ip: "{{ ansible_bond0.11['ipv4']['add

[ansible-project] Re: Managing Primary/Secondary relationship in cluster

2014-11-04 Thread James Martin
Ah, I didn't see that last line. Do a: - debug: var=partner Just to make sure you have your variables loading properly. On Tuesday, November 4, 2014 5:15:51 PM UTC-5, James Martin wrote: > > That indicates you haven't defined "partner" properly. Make sure it's > listed in the right pace in yo

[ansible-project] Re: Managing Primary/Secondary relationship in cluster

2014-11-04 Thread James Martin
That indicates you haven't defined "partner" properly. Make sure it's listed in the right pace in your inventory host_vars. On Tuesday, November 4, 2014 5:06:45 PM UTC-5, Barry Morrison wrote: > > {{ hostvars[partner]['ansible_eth0']['ipv4']['address'] }} << doesn't work > > "{'msg': "AnsibleUnd

[ansible-project] Re: Managing Primary/Secondary relationship in cluster

2014-11-04 Thread Barry Morrison
{{ hostvars[partner]['ansible_eth0']['ipv4']['address'] }} << doesn't work "{'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'partner' is undefined", 'failed': True}" in inventory/host_vars/server1.domain there is 'partner: server2.domain' On Tuesday, November 4, 2014 6:08:2

Re: [ansible-project] Error in play using 'lineinfile' module

2014-11-04 Thread Willard Dennis
Thanks, Tomasz, for the explanation -- wasn't aware that the 'lineinfile' module couldn't accept list input. Now, my question is: how to take a YAML list (such as the groups list in my vars file), form a string of the format of "group1 group2", and use that in lineinfile? On Tuesday, Novemb

Re: [ansible-project] Creating a file locally

2014-11-04 Thread Jacek Cała
Great, thanks! Jacek 2014-11-04 4:10 GMT+00:00 Brian Coca : > using delegate_to: localhost, local_action or connection: local with > file/copy/template should do the trick > > On Mon, Nov 3, 2014 at 7:42 PM, Jacek wrote: > >> Hi, >> >> Is there a way to ask ansible to create a file locally

Re: [ansible-project] playbook conditional include another playbook not wokring

2014-11-04 Thread Michael DeHaan
For starters, what ansible version are you using? On Tue, Nov 4, 2014 at 1:14 PM, jack wrote: > Thanks Brian. > > if condition is apply to the tasks level, the we will expect the task - > debug: msg="incude playbook0.yml" at playbook0.yml should be skipped, but > actually it is not. > > Here

Re: [ansible-project] Re: ansible >=1.7 fails unnecessarily by trying to open irrelevant vaults?

2014-11-04 Thread Michael DeHaan
It's going to be the case because we don't know if a template will reference a variable later. On Tue, Nov 4, 2014 at 7:09 AM, Barry Morrison wrote: > This has been a paint point for our team as well, asking for a vault > password when the playbook has nothing to do with vaulted items. Wish t

Re: [ansible-project] deploying with ansible

2014-11-04 Thread Michael DeHaan
I see yeah, the symlink for the shared folder could be part of the module, but could be outside it too. I'm fine with it being there if that's an example. On Mon, Nov 3, 2014 at 4:25 PM, Ramon de la Fuente wrote: > Hey Michael, > > Quick reply regarding the “shared folder” > > With most proje

Re: [ansible-project] Problem setting variable with bond0.11 IPv4 address from the gathered facts.

2014-11-04 Thread Matt Martz
To use a hostvar that contains a '.' you will need to do something such as: {{ hostvars[inventory_hostname]['ansible_bond0.11']['ipv4']['address'] }} On Tue, Nov 4, 2014 at 1:51 PM, Joel Sdc wrote: > Hi, > > I am using Ansible v1.7.1. > > I am having trouble using the gathered facts when an int

[ansible-project] Problem setting variable with bond0.11 IPv4 address from the gathered facts.

2014-11-04 Thread Joel Sdc
Hi, I am using Ansible v1.7.1. I am having trouble using the gathered facts when an interface has bonding and VLANs enabled: # ansible -m setup testserver [...] "ansible_bond0.11": { "active": true, "device": "bond0.11", "ipv4": { "a

Re: [ansible-project] playbook conditional include another playbook not wokring

2014-11-04 Thread jack
Thanks Brian. if condition is apply to the tasks level, the we will expect the task - debug: msg="incude playbook0.yml" at playbook0.yml should be skipped, but actually it is not. Here is result: $ ansible-playbook -i hosts playbook.yml --extra-vars="run1=true run0=false" PLAY [test-servers]

Re: [ansible-project] How to copy to remote servers

2014-11-04 Thread vinay . bhasker
Hello Michael: Can you please share a sample playbook to use fetch & copy operation? Thanks for your help. -Vinay On Thursday, October 30, 2014 10:04:40 AM UTC-7, Michael DeHaan wrote: > > Ansible "copy" works from the control machine, not between arbitrary sets > of servers. > > If you're ok w

Re: [ansible-project] playbook conditional include another playbook not wokring

2014-11-04 Thread Brian Coca
Conditions on include don't apply to the include itself, it is applied to the tasks included On Nov 4, 2014 1:00 PM, "jack" wrote: > I have problem at conditional include playbook: > > For example, I am following three simple playbooks: > > playbook0.yml: > --- > - hosts: test-servers > tasks:

[ansible-project] playbook conditional include another playbook not wokring

2014-11-04 Thread jack
I have problem at conditional include playbook: For example, I am following three simple playbooks: playbook0.yml: --- - hosts: test-servers tasks: - debug: msg="incude playbook0.yml" playboo1.yml: --- - hosts: test-servers tasks: - debug: msg="incude playbook1.yml" playbook.yml: ---

Re: [ansible-project] Accessing hashes of lists

2014-11-04 Thread James Morgan
Thanks, I think I need to reconsider my data structure. I need to be able to iterate over applications in a group in some situations but also key in by application name in others I'll have a think. Thanks On Tuesday, 4 November 2014 16:59:45 UTC, Matt Martz wrote: > > In your example, `apps.a

Re: [ansible-project] Accessing hashes of lists

2014-11-04 Thread Matt Martz
In your example, `apps.admin` actually contains a list of dictionaries. So accessing it would be: `apps.admin[0].service`. On Tue, Nov 4, 2014 at 10:55 AM, James Morgan wrote: > Hi, > > I need to store information about applications in a variable data > structure and access it via key. > > If I

[ansible-project] Accessing hashes of lists

2014-11-04 Thread James Morgan
Hi, I need to store information about applications in a variable data structure and access it via key. If I store the information as follows I can access using *with_items* - hosts: localhost connection: local vars: apps: admin: - service: admin handler: /admin

Re: [ansible-project] probably a dumb question, but ....

2014-11-04 Thread Tennis Smith
Hi Michael, Inline. -T Do you mean a galaxy role that takes a list of galaxy roles to suck down? > Exactly. > > That's an interesting idea, though I believe currently all roles need to > be "in" before ansible-playbook is invoked. > > Ah, ok. > It could be done in a two step process perhaps. >

Re: [ansible-project] Undefined variables

2014-11-04 Thread Michael DeHaan
That should be fine as long as it has no extension or .yml or .yaml so I wonder if you have something else in your playbook that might just be confusing, and it's not an issue with vault files being skipped. On Tue, Nov 4, 2014 at 1:28 AM, Arangel Angov wrote: > Hi Michael, > > That's all de

Re: [ansible-project] ansible -m setup takes extra 2 min on Fedora 20

2014-11-04 Thread Michael DeHaan
If someone can help isolate the slow methods on those systems, that would be great. We are not currently seeing this. On Mon, Nov 3, 2014 at 2:29 PM, Scott Sturdivant wrote: > Honestly I haven't bothered digging into ansible source, but here's my > results on Fedora 20, same as the OP: > > $

Re: [ansible-project] Include + with_items AGAIN.

2014-11-04 Thread Michael DeHaan
The 'v2/' tree refactoring may possibly allow this. Please be patient. On Tue, Nov 4, 2014 at 9:14 AM, Akos Vandra wrote: > Hello, > > I know, I know... It's getting boring, but... I keep bumping into this a > LOT. > > I would like to bring back include + with_items again. > > Consider having:

[ansible-project] Include + with_items AGAIN.

2014-11-04 Thread Akos Vandra
Hello, I know, I know... It's getting boring, but... I keep bumping into this a LOT. I would like to bring back include + with_items again. Consider having: - one nginx role - a few other roles, let's say it's a wordpress role for now. I'd like the nginx role to create a few sites that are giv

[ansible-project] Re: Managing Primary/Secondary relationship in cluster

2014-11-04 Thread James Martin
If you wanted to get the ip address of the first node in the production-cluster, you could do something like this. Think of the group as a list and 0 being the first element in the list. "{{ hostvars[groups['production-cluster'][0]]['ansible_eth0']['ipv4']['address'] }}" as far as your secon

[ansible-project] Preview of first 3 chapters of the new O'Reilly Ansible Book from Lorin Hochstein

2014-11-04 Thread Michael DeHaan
For those interested: http://www.ansible.com/ansible-book -- 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.

Re: [ansible-project] deploy artifacts - but download them only once, not for each host ?

2014-11-04 Thread Brian Coca
separate it into 2 plays, the first using hosts: localhost (or the control server), this runs all the tasks you only want to run once (downloads), the 2nd play can have the deploy to the target hosts. You can have multiple plays per file and per invocation. On Tue, Nov 4, 2014 at 7:00 AM, Torsten

[ansible-project] Re: ansible >=1.7 fails unnecessarily by trying to open irrelevant vaults?

2014-11-04 Thread Barry Morrison
This has been a paint point for our team as well, asking for a vault password when the playbook has nothing to do with vaulted items. Wish this weren't the case. On Thursday, October 30, 2014 3:01:01 PM UTC-7, Colin Nichols wrote: > > Hi all, > > I've been using ansible 1.6.x and I love it -- s

[ansible-project] deploy artifacts - but download them only once, not for each host ?

2014-11-04 Thread Torsten Reinhard
Hi, we are working on some playbooks that will deploy Maven artifacts (*.tar, *.zip) to our target environments. Due to the fact the target environment cannot directly access the Nexus Server (artifact repository) we need first to download them onto the control-machine - and copy/ synchronize f

[ansible-project] Managing Primary/Secondary relationship in cluster

2014-11-04 Thread Barry Morrison
I have a pair of servers (server1..domain, server2..domain) in two environments (staging and production). Server1 is primary, server2 is secondary. When I originally built the playbook, I had aliases in the inventory file [staging-cluster] primary server1.staging.domain secondary server2.stagi