[ansible-project] Dynamic inventory for rackspace cloud besides servers

2015-07-05 Thread Mehul Ved
Hi,
  I started a rackspace cloud database instance and tried to look for
ways to list it but can't find a way to list the database instances.
Is there a way to list different types of rackspace cloud instances as
we can do for rackspace cloud servers? Or the recommended way is to
register the new host during creation and write it to hosts file?


-- 
With Regards,
Mehul Ved

-- 
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/CADTL0oYG_Ww8Tx6%3DhY8K_epg3UoDB0eGnbVKSWcLfe_Y420LiQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: selectattr with ansible

2015-07-05 Thread Igor Cicimov
This works for me:

---
- hosts: localhost
  connection: local
  gather_facts: false
  vars:
   interfaces:
- name: lo0
  unit0:
ip_primary: 1.1.1.1
ip_secondary: 2.2.2.2
  unit1:
ip_primary: 3.3.3.3
ip_secondary: 4.4.4.4
- name: xyz
  unit0:
ip_primary: 9.9.9.9
  tasks:
   - set_fact:
  myip: |
   {%- set ips = [] -%}
   {% for interface in interfaces if interface.name == "lo0" %}
 {%- do ips.append(interface.unit0.ip_primary) -%}
   {%- endfor -%}
   {{ ips }}
   - debug: var=myip

$ ansible-playbook -i local test101.yml 

PLAY [localhost] 
** 

TASK: [set_fact ] 
* 
ok: [localhost]

TASK: [debug var=myip] 
 
ok: [localhost] => {
"var": {
"myip": [
"1.1.1.1"
]
}
}

PLAY RECAP 
 
set_fact  --- 
0.04s
debug var=myip -- 
0.00s
localhost  : ok=2changed=0unreachable=0failed=0



On Saturday, July 4, 2015 at 11:18:50 PM UTC+10, Vishal Chainani wrote:
>
> Hi,
>
> I have a list like below, and I need to select the sequence which has 
> "name" attribute equal to "lo0". I use this selectattr statement *{% set 
> lo0 = interfaces|selectattr("name", "equalto", lo0) | first%}*
>
> But while running the playbook throws me an error {'msg': 
> "TemplateRuntimeError: no test named 'equalto'", 'failed': True}
>
> interfaces:
> - name: lo0
>   unit0:
> ip_primary: 1.1.1.1
> ip_secondary: 2.2.2.2
>   unit1:
> ip_primary: 3.3.3.3
> ip_secondary: 4.4.4.4
> - name: xyz
>   unit0:
> ip_primary: 9.9.9.9
>
> Jinja2 version 2.7.3.
>
> Any pointer what am I  missing?
>
>
> Vishal
>

-- 
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/862068e6-1c55-4e2e-a671-b28c3cc03d82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: selectattr with ansible

2015-07-05 Thread Nico K.
In your example, the loop variable is named identical to your list variable.

Try doing:

{% for interface in interfaces if interface.name == "lo0" %} 
{{ interface.unit0.ip_primary }}
{% endfor %}

On Sunday, July 5, 2015 at 4:03:08 PM UTC+2, Vishal Chainani wrote:
>
> Hmmm
>
> so if have to select the list based on the value one of its key, is it 
> possible?
>
> I am trying something like this:
>
>
>
> *{% for interfaces in interfaces if interfaces.name 
>  == "lo0" %}{{ interfaces.unit0.ip_primary }}{% 
> endfor %}*
>
> But throws an error {'msg': "AnsibleUndefinedVariable: One or more 
> undefined variables: 'list object' has no attribute 'lo0'", 'failed': True}
>
> Any ideas?
>
> Vishal
>
> On Sunday, July 5, 2015 at 1:47:19 PM UTC+5:30, Igor Cicimov wrote:
>>
>> I think the 'equalto' test is only available in the 2.8+ version of jinja2
>
>

-- 
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/712d82f3-6306-4471-8049-e20aa9cb1d84%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: jinja syntax error in lookup template says "can't read file"

2015-07-05 Thread Barry Kaplan
Seems the trick is to run the template thru the template action directly:

  template:
src: ../files/prometheus/prometheus.yml.j2
dest: /tmp/p.yml

Then you get a proper error message:

TASK: [TEST TEST] 
*
fatal: [10.0.196.193] => {'msg': "AnsibleUndefinedVariable: One or more 
undefined variables: 'prometheus_consul_dcs' is undefined", 'failed': True} 

-- 
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/0aa23cb2-7243-473b-8217-a97a9100ee45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] jinja syntax error in lookup template says "can't read file"

2015-07-05 Thread Barry Kaplan
I have  template that contains

  - job_name: nodes
consul_sd_configs:
  {% for cenv in prometheus_consul_dcs %}
  {% endfor %}

This loads fine with 

  prometheus_yml: "{{lookup('template', 
'../files/prometheus/prometheus.yml.j2')}}"

But when I add a loop

  - job_name: nodes
consul_sd_configs:
  {% for cenv in prometheus_consul_dcs %}
  {% endfor %}

I get an error saying the file can't read. 

TASK: [prometheus | Create prometheus configuration file] 
*

fatal: [10.0.196.193] => Failed to template {{lookup('template', 
'../files/prometheus/prometheus.yml.j2')}}: unable to read /Users/bkaplan/si
/ops/ansible/roles/prometheus/files/prometheus/prometheus.yml.j2

I guess one could argue that "can't read" is not the same as "can't find" 
and this should be interpreted as an error in the file. Is there any way to 
get the actual error from jinja?

-- 
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/361f9f6e-509e-4ccf-836d-2c96a9d1152b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] why is this task hanging? (shell module)

2015-07-05 Thread Brian Coca
The reason it is 'hanging' is because you are not detaching from the
console, this is not the recommended way of running services, I would
use an init/rc script or upstart/systemd config. But if you MUST do it
this way, try prepending nohup.



-- 
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...@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/CAJ5XC8m2sXj%2BGS8Kxg8jZSce7mMzGsEXnNODQ5GXmaXVKyMVrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible seems can not parse response from remote host due to locale issue.

2015-07-05 Thread Brian Coca
ansible does not require an agent, it does require python with json
installed on the target though (as documented here
http://docs.ansible.com/intro_installation.html#managed-node-requirements).
With out it you can still use ansible, but limited to the raw module
(normally used to install python).



-- 
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...@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/CAJ5XC8k1zi5NL9-Q45LLMJ0%3DdogXNbuD1sXWB9jTsZEFEnwkHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] failed_when/changed_when with script module

2015-07-05 Thread Aaron Schrab
I'm using ansible 2.0, and I'm trying to create a script play which will 
correctly flag when a change was made, but so far I've been unable to get 
this to work.  Here's what I have for the play:

- script: script {{ arg }}
  register: command_result
  failed_when: command_result.rc != 0 and command_result.rc != 1
  changed_when: command_result.rc == 1

The script runs correctly, and reports success if no change happens. But, 
if it exits with code 1 to indicate that a change was made ansible is 
reporting that it failed:

fatal: [vagrant]: FAILED! => {"stdout": "", "changed": true, "failed": 
false, "stderr": "", "rc": 1, "failed_when_result": false}

I've also tried using:

- script: script {{ arg }}
  register: command_result
  changed_when: "'updated' in command_result.stderr"

With the script using stderr rather than the exit status to report the 
change, but in that case ansible never reports that a change was made.

Is ideas about what I'm doing wrong?

Thanks.

-- 
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/c0b47c34-7c24-4efe-b238-c3b1e07006bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Privileges when testing Playbooks on Vagrant VMs before running on production machines

2015-07-05 Thread Anthony Green
Background: 
I'm exploring using Ansible to provision a CI master/slave set for EtE 
testing. 
I'm using Vagrant to build VMs on my local workstation.

Vagrant creates it's VMs with a default vagrant user that has SUDO 
privileges. 
The user created during a Ubuntu installation on the production machine 
doesn't (haven't verified this yet)

So I've found certain  tasks that don't require SUDO to run on the Vagrant 
VM do require it on the production machines.

Question:
Is there a favoured approach for unifying tasks that will run against both 
situations?
- Add the same production user name account to the Vagrant image?
- Add the user on the production box to SUDOERS using Ansible?
- Add sudo yes to the hosts file?
- Something else?

-- 
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/bc7256ba-6c4c-4b75-bab1-3278579932d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] why is this task hanging? (shell module)

2015-07-05 Thread Willard Dennis
Hi all,

Wrote a task as follows:

- name: Bootstrap Consul servers
  shell: /usr/local/bin/consul agent -server -bootstrap-expect 3 -data-dir 
/tmp/consul -dc nyc3 -bind {{ ansible_default_ipv4.address }} >> {{ 
consul_log_file }} 2>&1
  tags: bootconsulsvrs

When my playbook gets to this task, it hangs... (but it does successfully 
start the desired program...) How can I rewrote this so that the playbook 
continues?

Thanks,
Will

-- 
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/ff64d06a-3903-4bef-9c1f-d22fc64c80f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] group_vars on many groups ?

2015-07-05 Thread Serge van Ginderachter
On 2 July 2015 at 17:05, Charly Koza  wrote:

> Hello !
>
> I somehow need to
> - assign applications to groups of hosts
> - have a host in several groups in the platform
> - get the list of deployed applications in the platform
> - be able to get the list of hosts with the application.
>
> I tried like that :
>
> I'm trying to have a variable (dokku_apps) defined for multiple groups.
> depending on the target server (testing, prod, and so on), a single host
> can use many groups or only one.
>
> the idea is that a group should configure some dokku apps. so if a host is
> in many groups it should configure dokku apps specific to each of its group
>
> my problem is that when a host is in many groups, the dokku_apps
> (configured in group_vars) is only from a single group (the latest i think)
> and is not merged (as expected from documentation)
>
> I'm also using this list (dokku_apps) to configure varnish.
>
> How can i achieve that ?
>

​Given that variables are merged according to group priorities, and there
is no some default way to add-up some lists, this is hard to achive
cleanly.​

A workaround might be to put this data in dictionaries, and enable dict
merging in ansible.cfg


TBH, I never found a clean wat to do this kind of construct. It should be
something we want to enable when revamping inventory things.

-- 
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/CAEhzMJDUfj40_pimXVQJ66vhR93mc4%3D3eHsMS8OXHwE0_cowDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: selectattr with ansible

2015-07-05 Thread Vishal Chainani
Hmmm

so if have to select the list based on the value one of its key, is it 
possible?

I am trying something like this:



*{% for interfaces in interfaces if interfaces.name == "lo0" %}{{ 
interfaces.unit0.ip_primary }}{% endfor %}*

But throws an error {'msg': "AnsibleUndefinedVariable: One or more 
undefined variables: 'list object' has no attribute 'lo0'", 'failed': True}

Any ideas?

Vishal

On Sunday, July 5, 2015 at 1:47:19 PM UTC+5:30, Igor Cicimov wrote:
>
> I think the 'equalto' test is only available in the 2.8+ version of jinja2

-- 
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/59e491f7-e8b1-4ea1-b62f-5a29e2059e41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] List and Dict combined

2015-07-05 Thread Vishal Chainani
That works, thanks!

On Sunday, July 5, 2015 at 5:10:18 PM UTC+5:30, Jan Grant wrote:
>
> Not quite, but you can have a dictionary member whose value is a list: 
>
> snmp: 
>   location: xyz 
>   contact: admin 
>   community: 
> - name: public 
>   access: read-only 
>   clients: 
> - hosts: 8.8.8.8 
> - hosts: 10.10.10.10 
> - name: private 
>   access: read-write 
>   clients: 
> - hosts: 3.3.3.3 
> - hosts: 4.4.4.4 
>
> And here, each element of the 'community' list is a dict. 
>
>
> On Sun, 5 Jul 2015, Vishal Chainani wrote: 
>
> > Hi, 
> > 
> > Can a list have a combination of dict and lists? Below is my data and 
> > jinja2 template, while running the play book get an error. 
> > 
> > snmp: 
> >   location: xyz 
> >   contact: admin 
> > - community: 
> > name: public 
> > access: read-only 
> > clients: 
> >   - hosts: 8.8.8.8 
> >   - hosts: 10.10.10.10 
> > - community: 
> > name: private 
> > access: read-write 
> > clients: 
> >   - hosts: 3.3.3.3 
> >   - hosts: 4.4.4.4 
> > 
> > snmp { 
> > location "{{ snmp.location }}""; 
> > contact "{{ snmp.contact }}";" 
> > {% for snmp in snmp %} 
> > community {{ snmp.community.name }} { 
> > authorization {{ snmp.community.access }}; 
> > clients { 
> > {% for client in snmp.community.clients %} 
> > {{ client.hosts }}; 
> > {% endfor %} 
> > } 
> > } 
> > {% endfor %} 
> > } 
> > 
> > (ansible)Vishals-MBP:ansible vishalc$ ansible-playbook main.yml 
> > ERROR: Syntax Error while loading YAML script, 
> > /etc/ansible/group_vars/lab.yml 
> > Note: The error may actually appear before this position: line 27, 
> column 5 
> > 
> >   contact: admin 
> > - community: 
> > ^ 
> > 
> > Vishal 
> > 
> > -- 
> > 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/17d716b2-0180-45a1-8c49-f61e6ef88ecd%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
> > 
>
> -- 
> ja...@ioctl.org   http://ioctl.org/jan/ Short, dark, ugly: 
> pick any three 
> The only certain way to prevent another 9/11 is via universal calendar 
> reform. 
>

-- 
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/17eb2088-7df8-456f-bff1-ed841ac9a9f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: template + delegate_to + ssh shared connections = closed connections

2015-07-05 Thread Shay Rojansky
Thanks for pointing out the bug Nathan! I'll add my vote.

On Thursday, July 2, 2015 at 8:11:28 PM UTC+3, Nathan Brown wrote:
>
> Actually I was wrong. Forgot to tear town my control sockets when swapping 
> server versions.
>
> This is entirely the fault of the ConsoleKit patch, at least for Ubuntu 
> 14.04
>
> https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/1334916/
>
> On Thursday, July 2, 2015 at 6:04:54 AM UTC-7, Nathan Brown wrote:
>>
>> I ran into this today and played around with different server and client 
>> versions of OpenSSH. My environment consists of servers running Ubuntu 
>> 14.04 and clients running OSX.
>>
>> If you run OSX, this problem will go away if you `brew install openssh`.
>>
>> On the server I tested these openssh versions:
>> - Default: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2, OpenSSL 1.0.1f 6 Jan 2014
>> - Latest: OpenSSH_6.9p1, OpenSSL 1.0.1f 6 Jan 2014
>>
>> On the client I tested these openssh clients:
>> - Default: OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
>> - Latest (brew): OpenSSH_6.8p1, OpenSSL 1.0.2a 19 Mar 2015
>>
>>
>> On Monday, June 15, 2015 at 6:22:55 AM UTC-7, Shay Rojansky wrote:
>>>
>>> FYI, after working with paramiko for a while I still have issues when 
>>> delegating multiple tasks to the same host, this time with the error "Error 
>>> reading SSH protocol banner".
>>>
>>> On Wed, Jun 10, 2015 at 7:31 PM, Shay Rojansky  wrote:
>>>
 Great to hear, thanks!

 On Wed, Jun 10, 2015 at 5:11 PM, Brian Coca  wrote:

> the issue is that under normal operation you are hitting different
> hosts, when delegating you may have several forks hitting the same
> host, which when you factor in control master ssh sockets, it can get
> complicated. paramiko avoids this by not having a shared resource.
>
> in 2.0 we've added some code that does a better job of dealing with
> this multiconcurrency when using ssh.
>
> On Wed, Jun 10, 2015 at 5:39 AM, Shay Rojansky  wrote:
> > I can confirm that switching to paramiko appears to solve the 
> problem in my
> > case. This seems like a bit of a shame openssh is the recommended 
> way to go
> > (more features).
> >
> > On Mon, Jun 8, 2015 at 8:05 PM, Shay Rojansky  
> wrote:
> >>
> >> I was just looking into that, is that a reliable workaround?
> >>
> >> Will try soon and report the results.
> >>
> >> On Mon, Jun 8, 2015 at 8:02 PM, Brian Coca  
> wrote:
> >>>
> >>> have you tried switching to paramiko as your connection?
> >>>
> >>> On Mon, Jun 8, 2015 at 1:00 PM, Shay Rojansky  
> wrote:
> >>> > I have this issue as well: running a play which delegates some 
> action
> >>> > to the
> >>> > same host pretty consistently fails with the above error. 
> Findings are
> >>> > exactly the same as below, including the -f 1 behavior.
> >>> >
> >>> > Any ideas on workarounds?
> >>> >
> >>> >
> >>> > On Friday, May 29, 2015 at 3:36:33 PM UTC+3, Christian Rusa 
> wrote:
> >>> >>
> >>> >> I can confirm this problem.
> >>> >>
> >>> >> In my case it is a playbook which creates a configuration file 
> for the
> >>> >> server on the backupserver.
> >>> >>
> >>> >> If I run this playbook against 1 host it works.
> >>> >> If I run it against a group of hosts it fails.
> >>> >> If I run it against a group of host using -f 1 as parameter it 
> works.
> >>> >>
> >>> >> Error is always the SSH Error: Shared connection to x 
> closed.
> >>> >>
> >>> >> Ansible version is 1.9-0.git201503262158~unstable
> >>> >>
> >>> >>
> >>> >>
> >>> >>
> >>> >> On Monday, May 11, 2015 at 4:47:14 PM UTC+2, Cory Wagner wrote:
> >>> >>>
> >>> >>> I didn't try with serial, but I have not had an issue when 
> running
> >>> >>> the
> >>> >>> same playbook against one or two delegates.
> >>> >>>
> >>> >>> On Thursday, April 30, 2015 at 9:35:57 AM UTC-5, Brian Coca 
> wrote:
> >>> 
> >>>  this sounds like a probably race condition with the per host 
> forks
> >>>  interfering with each other, try setting serial: 1 to confirm.
> >>> 
> >>> 
> >>> 
> >>>  --
> >>>  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-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/e459b939-0395-4d33-acc9-224ee29f0fe9%40googlegroups.com
> .
> >>> >
> >>> > For more options, vi

Re: [ansible-project] alter PATH for all tasks running on a specific host group?

2015-07-05 Thread Brian Coca
It can be set at play level.

-- 
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/CAJ5XC8kD0cLqA6hhPPf6ALJ4Z1OEQ5gwBWBMVPeXMsCOrOqUaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] List and Dict combined

2015-07-05 Thread jang
Not quite, but you can have a dictionary member whose value is a list:

snmp:
  location: xyz
  contact: admin
  community:
- name: public
  access: read-only
  clients:
- hosts: 8.8.8.8
- hosts: 10.10.10.10
- name: private
  access: read-write
  clients:
- hosts: 3.3.3.3
- hosts: 4.4.4.4

And here, each element of the 'community' list is a dict.


On Sun, 5 Jul 2015, Vishal Chainani wrote:

> Hi,
> 
> Can a list have a combination of dict and lists? Below is my data and 
> jinja2 template, while running the play book get an error.
> 
> snmp:
>   location: xyz
>   contact: admin
> - community:
> name: public
> access: read-only
> clients:
>   - hosts: 8.8.8.8
>   - hosts: 10.10.10.10
> - community:
> name: private
> access: read-write
> clients:
>   - hosts: 3.3.3.3
>   - hosts: 4.4.4.4
> 
> snmp {
> location "{{ snmp.location }}"";
> contact "{{ snmp.contact }}";"
> {% for snmp in snmp %}
> community {{ snmp.community.name }} {
> authorization {{ snmp.community.access }};
> clients {
> {% for client in snmp.community.clients %}
> {{ client.hosts }};
> {% endfor %}
> }
> }
> {% endfor %}
> }
> 
> (ansible)Vishals-MBP:ansible vishalc$ ansible-playbook main.yml 
> ERROR: Syntax Error while loading YAML script, 
> /etc/ansible/group_vars/lab.yml
> Note: The error may actually appear before this position: line 27, column 5
> 
>   contact: admin
> - community:
> ^
> 
> Vishal
> 
> -- 
> 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/17d716b2-0180-45a1-8c49-f61e6ef88ecd%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> 

-- 
j...@ioctl.org  http://ioctl.org/jan/ Short, dark, ugly: pick any three
The only certain way to prevent another 9/11 is via universal calendar reform.


Re: [ansible-project] Ansible seems can not parse response from remote host due to locale issue.

2015-07-05 Thread fengnan zhao

On Sunday, 5 July 2015 03:07:30 UTC+10, Brian Coca wrote: 
>
> The issue seems to be that it is not finding python, its looking at 
> /usr/bin/python, if python is elsewhere use ansible_python_interpreter 
> for that host to point to the correct location. 
>
> -- 
> Brian Coca 
>
 
thanks Brian - that is exactly the problem.  Tffxa04z doesn't have python 
installed. 
 
However,   we assumed the ansible doesn't rely on the the python/agent 
installed  on the managed node - and that is why we chose Ansible over 
other tools ( puppet, chef or Salt ) . 
Is the SSHD running on the controlled node good enough ? 
 
Our assumption seems to be wrong ... 
 
thanks & Regards

-- 
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/86da1f54-511f-418b-83d4-710bda91268d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] alter PATH for all tasks running on a specific host group?

2015-07-05 Thread Alex Peters
I appreciate the suggestion, but this would still require modifying every 
task in every role that applies to this particular host group.

Is there any way to influence the environment of a host or host group 
without resorting to such per-task modifications?

On Monday, 18 May 2015 22:21:42 UTC+10, Brian Coca wrote:
>
> try 
>
> environment: "{{mysettings}}" 
>
> where mysettings is a group var 
>
> On Sat, May 16, 2015 at 10:55 PM, Alex Peters  > wrote: 
> > I have a couple playbooks that apply to a number of host groups, one 
> group 
> > having /sbin (among other things) missing from its hosts' PATHs. 
> > 
> > This means that the playbooks run correctly on most hosts, but not the 
> hosts 
> > in that particular group. 
> > 
> > I realise that I can alter the playbooks' affected tasks to manually set 
> the 
> > PATH using the environment parameter.  This solution is not ideal though 
> > because it's addressing an issue relevant to the group, not the 
> playbooks 
> > themselves. 
> > 
> > I'd prefer to somehow have this information in a group var only.  Is it 
> > possible to define a group var that causes the hosts in that group to 
> have a 
> > modified PATH when running tasks?  Do other solutions exist to this 
> problem? 
> > 
> > -- 
> > 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/91f386a7-914f-4b57-9838-e99d4b7cb67e%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
> 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...@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/7f69d410-84a7-4da7-a83b-fe546ff7c880%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] selectattr with ansible

2015-07-05 Thread Igor Cicimov
I think the 'equalto' test is only available in the 2.8+ version of jinja2

-- 
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/210c12a5-9a29-4fba-aef6-46b9fdcc68db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] List and Dict combined

2015-07-05 Thread Vishal Chainani
Hi,

Can a list have a combination of dict and lists? Below is my data and 
jinja2 template, while running the play book get an error.

snmp:
  location: xyz
  contact: admin
- community:
name: public
access: read-only
clients:
  - hosts: 8.8.8.8
  - hosts: 10.10.10.10
- community:
name: private
access: read-write
clients:
  - hosts: 3.3.3.3
  - hosts: 4.4.4.4

snmp {
location "{{ snmp.location }}"";
contact "{{ snmp.contact }}";"
{% for snmp in snmp %}
community {{ snmp.community.name }} {
authorization {{ snmp.community.access }};
clients {
{% for client in snmp.community.clients %}
{{ client.hosts }};
{% endfor %}
}
}
{% endfor %}
}

(ansible)Vishals-MBP:ansible vishalc$ ansible-playbook main.yml 
ERROR: Syntax Error while loading YAML script, 
/etc/ansible/group_vars/lab.yml
Note: The error may actually appear before this position: line 27, column 5

  contact: admin
- community:
^

Vishal

-- 
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/17d716b2-0180-45a1-8c49-f61e6ef88ecd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.