[ansible-project] Re: add_host access host variables from in-memory group

2015-10-30 Thread K Cheng
Doesn't matter, I've used add_host and then called the group using hosts 
instead and I'll just delegate back down to the localhost to perform the 
actions I need it to instead.

Karen

On Thursday, October 29, 2015 at 11:37:47 AM UTC+10, K Cheng wrote:
>
> Hey guys,
>
> Just wondering whether there is a way to access the contents of a add_host 
> group?
>
> EG:
>
> - name: Add newly created instance to host group created_instances
>   add_host: 
> hostname: "{{ item.private_ip }}"
> testvar: test_variable
>
> public_one: "{{ item.public_ip }}" 
>
> groups: created_instances
>   with_items: "{{ ec2.instances | default({}) }}"
>
>
>
>   - name: Get specific data from newly created instances
>
>  debug: var="{{ item.testvar }}
>
>  with_items: created_instances 
>
>
>
> At the moment, when I do the above, item is only the IP address (private 
> ip address) and I can't seem to get at anything specific. I'm using dynamic 
> inventory and I was hoping not to have to rerun the dynamic inventory again 
> seeing as I thought add_host was supposed to add details to in-memory 
> groups.
>
> Regards
>
> Karen 
>

-- 
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/1a868fdc-dcb7-436f-8582-800a9d678b39%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Execute task when: "'Key' not in object"

2015-10-30 Thread Rob Wilkerson
I have a playbook that's creating _n_ EC2 instances using exact_count. I'd 
like to tag those instances with a semi-meaningful Name value. I can get a 
list of all of my tagged instances from the ec2 module return value using 
{{ servers.tagged_instances }}, but...

I only want to apply a Name tag to those that don't already have one.

- name: Instances | Tag each instance with a name
  ec2_tag:
aws_access_key: "{{ awscli.access_key }}"
aws_secret_key: "{{ awscli.secret_key }}"
region: "{{ aws.region }}"
resource: "{{ item.1.id }}"
state: present
tags:
  Name: "{{ env_short }}-{{ 'ws%02d' | format(item.0) }}"
  with_indexed_items: webservers.tagged_instances
  when: "'Name' not in item.tags.keys()"  # Untagged instances only

I've tried several variations of the `when` stanza, but nothing's worked. 
Likewise, I haven't found any documentation with an example like this. Is 
it possible?

-- 
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/f917f2c7-f592-4ba3-9ebf-19bfb166fd0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] find module parse return value

2015-10-30 Thread Eugene Polyanichko
Thanks a lot for reply. You saved my day. I've been pulling my hair off for 
like 4 hours and the problem was simply in wrong "dest" value, because I 
didn't see my mistake and treated error output not the way it should be :)
with_items and item.path works of course

On Friday, October 30, 2015 at 10:29:42 PM UTC+2, Brian Coca wrote:
>
> item would be a dictionary, I'm assuming what you want is a path: 
>
>  lineinfile: dest={{ item.path }} 
>
> - 
> 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/d7c29401-8066-4ce9-bc93-149e1acfc53e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] find module parse return value

2015-10-30 Thread Brian Coca
item would be a dictionary, I'm assuming what you want is a path:

 lineinfile: dest={{ item.path }}

-
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/CAJ5XC8%3Dwfyt%3DG8mWs1%2B7rDrHVk9%3DV8m2sx_4FPhqYMSrHZ9Teg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] find module

2015-10-30 Thread Eugene Polyanichko
How one can parse find module results? Official manual 
http://docs.ansible.com/ansible/find_module.html states, that value "files" 
is type of "list of dictionaries", but I find no way to have nested loops 
of different types (with_dict inside with_items).

-- 
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/07e19fb4-9625-4f97-997c-f6f7b246cdf6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] find module parse return value

2015-10-30 Thread Eugene Polyanichko
Official documentation http://docs.ansible.com/ansible/find_module.html 
states, that main return value name is files and it's "list of 
dictionaries". Does anyone know how to parse this value? I've tried all 
possible loops, but I can't figure out how to loop properly. I've read docs 
dozens of times, googled and nothing.

Basic code:

- name: Get files
 find: paths="/etc/" patterns="*"
 register: find_results

- name: Make sure line is present
  lineinfile: dest=/etc/cron.d/{{ item }} insertbefore=BOF line="123"
  with_items: find_results.files

This example doesn't work, obviously, because as far as i understand, to 
traverse "list of dictionaries" you need to have with_dict inside 
with_items, but I don't see a way to have nested loops of different types.

-- 
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/306d8fa4-e907-4801-b090-08fde39daf94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] roster: an Ansible dynamic inventory tool for Terraform projects

2015-10-30 Thread george hartzell
Hi All,

I'd like to share [roster](https://github.com/hartzell/roster).

Roster is a tool for working transforming Terraform state information
into other forms (it's original calling was as an Ansible dynamic
inventory provider).  It is intended to be "go get'able".

I'd appreciate any feedback all y'all have to offer on go issues,
Ansible issues and/or Terraform issues.  I'm particularly interested
in extending the set of Terraform providers it supports and making my
go better.

It uses terraform's routines to work with the state information, which
seems better than reverse engineering the state files themselves. But,
these routines are not mainstream, so we'll have to see what happens
going forward. More info in
[terraform issue 3405](https://github.com/hashicorp/terraform/issues/3405).

It uses Go templates to generate it's output. One can dump out these
templates, e.g.:

$ ./roster dump-template /templates/dynamic-inventory

and see what it's doing. One can also supply one's own templates

$ ./roster execute-template myTemplate.txt

Roster parses state data for instances from:

- OpenStack
  - the instance name is used as the Name
  - the access_ip_v4 is used as the Address
  - host_vars and groups can be specified in the resource configuration
metadata section like so:

metadata {
ansible_groups = "foo,  bar"
ansible_host_vars = "color=red, importance=high"
}

Parsing those strings is very unsophisticated, I'm waiting for
better use cases before I get fancy.

- DigitalOcean
  - the name is used as the Name
  - the ipv4address is used as the Address
  - there is no support for groups or hostvars

- Cloudstack
  - the name is used as the Name
  - the ipaddress is used as the address
  - there is no support for groups or hostvars

- AWS
  - I have *preliminary* support for AWS instances, BUT
  - Every instance is named "moose", I can't figure out what info to use
as the Name.
  - If an instance has a public_ip, that is used as the Address, if not
and it has a private_ip then that is used.

Let me know if you find it useful.

g.

-- 
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/26cf1b27-f8d7-4333-ac44-da19239a8293%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] SSH Connection does not complete.

2015-10-30 Thread Jon Dison
When attempting to run an ansible module on a remote host, the SSH 
connection never fully completes...

[myhost myusername 11:46:23]~ $ ansible -v -m setup -i 
~/dave_ansible/ansible/hosts.txt remotehost -u user -k -K --sudo
SSH password: 
SUDO password[defaults to SSH password]: 
 ESTABLISH CONNECTION FOR USER: user
 REMOTE_MODULE setup
 EXEC sshpass -d7 ssh -C -tt -vvv -o ControlMaster=auto -o 
ControlPersist=60s -o ForwardAgent=yes -o 
ControlPath="/home/myusername/.ansible/cp/ansible-ssh-%h-%p-%r" -o 
GSSAPIAuthentication=no -o PubkeyAuthentication=no -o User=user -o 
ConnectTimeout=10 remotehost /bin/sh -c 'mkdir -p 
$HOME/.ansible/tmp/ansible-tmp-1446223631.25-150226097303689 && chmod a+rx 
$HOME/.ansible/tmp/ansible-tmp-1446223631.25-150226097303689 && echo 
$HOME/.ansible/tmp/ansible-tmp-1446223631.25-150226097303689'


Watching the connection on the far side, this is as far as it gets:

Oct 30 11:47:11 remotehost sshd[12366]: debug1: Forked child 12369.
Oct 30 11:47:11 remotehost sshd[12369]: Set /proc/self/oom_score_adj to 0
Oct 30 11:47:11 remotehost sshd[12369]: debug1: rexec start in 5 out 5 
newsock 5 pipe 7 sock 8
Oct 30 11:47:11 remotehost sshd[12369]: debug1: inetd sockets after 
dupping: 3, 3
Oct 30 11:47:11 remotehost sshd[12369]: Connection from 1.2.3.4 port 48580
Oct 30 11:47:11 remotehost sshd[12369]: debug1: Client protocol version 
2.0; client software version OpenSSH_6.2
Oct 30 11:47:11 remotehost sshd[12369]: debug1: match: OpenSSH_6.2 pat 
OpenSSH*
Oct 30 11:47:11 remotehost sshd[12369]: debug1: Enabling compatibility mode 
for protocol 2.0
Oct 30 11:47:11 remotehost sshd[12369]: debug1: Local version string 
SSH-2.0-OpenSSH_5.3
Oct 30 11:47:11 remotehost sshd[12370]: debug1: permanently_set_uid: 74/74
Oct 30 11:47:11 remotehost sshd[12370]: debug1: list_hostkey_types: 
ssh-rsa,ssh-dss
Oct 30 11:47:11 remotehost sshd[12370]: debug1: SSH2_MSG_KEXINIT sent
Oct 30 11:47:11 remotehost sshd[12370]: debug1: SSH2_MSG_KEXINIT received
Oct 30 11:47:11 remotehost sshd[12370]: debug1: kex: client->server 
aes128-ctr hmac-md5 
Oct 30 11:47:11 remotehost sshd[12370]: debug1: kex: server->client 
aes128-ctr hmac-md5 
Oct 30 11:47:11 remotehost sshd[12370]: debug1: SSH2_MSG_KEX_DH_GEX_REQUEST 
received
Oct 30 11:47:11 remotehost sshd[12370]: debug1: SSH2_MSG_KEX_DH_GEX_GROUP 
sent
Oct 30 11:47:11 remotehost sshd[12370]: debug1: expecting 
SSH2_MSG_KEX_DH_GEX_INIT
Oct 30 11:47:11 remotehost sshd[12370]: debug1: SSH2_MSG_KEX_DH_GEX_REPLY 
sent
Oct 30 11:47:11 remotehost sshd[12370]: debug1: SSH2_MSG_NEWKEYS sent
Oct 30 11:47:11 remotehost sshd[12370]: debug1: expecting SSH2_MSG_NEWKEYS
Oct 30 11:47:11 remotehost sshd[12370]: debug1: SSH2_MSG_NEWKEYS received
Oct 30 11:47:11 remotehost sshd[12370]: debug1: KEX done
Oct 30 11:47:11 remotehost sshd[12370]: debug1: userauth-request for user 
user service ssh-connection method none
Oct 30 11:47:11 remotehost sshd[12370]: debug1: attempt 0 failures 0
Oct 30 11:47:11 remotehost sshd[12369]: debug1: PAM: initializing for "user"
Oct 30 11:47:11 remotehost sshd[12369]: debug1: PAM: setting PAM_RHOST to 
"1.2.3.4"
Oct 30 11:47:11 remotehost sshd[12369]: debug1: PAM: setting PAM_TTY to 
"ssh"
Oct 30 11:47:11 remotehost sshd[12370]: debug1: userauth_send_banner: sent

-- 
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/8dfa1358-9e2c-4146-91f9-bfc34135e4dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Playbook execution

2015-10-30 Thread Trimurtulu k


Hello Forum,

How to execute a playbook remotely with password?

Ex:ansible-playbook  -k

Thanks,

Trim

-- 
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/4991af98-c80c-4b42-af02-74d581c61752%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] playbook execution remotely

2015-10-30 Thread Trimurtulu k


Hello Forum,

How to execute a playbook remotely with password?

Ex:ansible-playbook  -k

Thanks,

Trim

-- 
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/10702c71-7893-4f1f-b3f0-ea5274811f80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Galaxy 1.1.1 release

2015-10-30 Thread Chris Houseknecht
Galaxy  1.1.1 is live.

--Chris

On Thursday, October 29, 2015 at 4:40:21 PM UTC-4, Chris Houseknecht wrote:
>
> We will be releasing Galaxy 1.1.1 tomorrow at 8:00 AM EDT.  This a small 
> maintenance release addressing a handful of minor bugs. There will be no 
> interruption of service during the deployment. 
>
> The complete list of bug fixes included in release 1.1.1 can be found 
> here. 
> 
>
>
>
> Chris Houseknecht
> Lead Galaxy Engineer
> chouseknecht at ansible.com
>
>
>

-- 
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/4dfde956-47c8-4e4a-bf56-5fdc4709b94e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] unpredictable 'working directory' on local machine

2015-10-30 Thread Jonathan Miller


On Tuesday, 27 October 2015 16:34:10 UTC, Brian Coca wrote:
>
> I see what you mean now, but not unpredictable. Lookups are always 
> relative to the role or play.
>
> Local tasks are relative to the cwd from which you execute.
>
>
> -- 
> Brian Coca
>

Thanks, that is excellent info.
I have not found this documented anywhere.

-- 


Follow us on:     
  



Appsbroker Consulting Limited, Registered office: Appsbroker House, The 
Square, Swindon,
SN1 3EB, Company Number: 5702796, VAT Number: GB 876 3533 92, Company 
registered in England and Wales.

PLEASE NOTE AS RECIPIENT OF THIS EMAIL: Any views or opinions presented are 
solely those of the author and do not represent those of Appsbroker 
Consulting Limited. This e-mail is confidential and intended solely for the 
addressee. If you are not the intended recipient, be advised that you have 
received this mail in error and that any use, dissemination, forwarding, 
printing or copying of this e-mail is strictly prohibited. Furthermore, if 
you are not the intended recipient, please email it back to the sender and 
then immediately permanently delete it.

-- 
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/a66fff30-54e1-4ab0-949a-4805dec68f60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Task/inventory option preference

2015-10-30 Thread jonas . haag
Brian, thanks for the clarification. Do you happen to know if there's some 
way to make sure in a task that we're NOT connected with become=yes?

The reason I started this conversation is because I faced issues with 
debops/ansible-core, which expects some task to be execute without become. 
I wanted to contribute a patch there to prevent other people from hitting 
the same issue and not knowing what's going wrong. The task I'm talking 
about 
is 
https://github.com/debops/ansible-core/blob/d07d9e71e6a25656df8c4111b3f46f0edb30942c/tasks/main.yml#L19.

I thought about first using `whoami` on the remote machine to ensure we're 
not root. But you'd have to be more general than comparing with "root" 
because people might become some other user as well. This approach could 
work if there's some way in the task to read out ansible_become_user (which 
is, to some extent, the generalization of "root").

-- 
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/18e06ddd-f907-4f5f-8307-120ffcf5da00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Running parallely a playbook on the same host but with different values of the same extra var

2015-10-30 Thread Roger Simon
many thanks 
it work fine 


Le lundi 26 octobre 2015 16:17:57 UTC+1, Brian Coca a écrit :
>
> define the same host with diff inventory_hostnames, assigne the values 
> to the same host var. 
>
>
>
> -- 
> 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/0eff834d-e6aa-4707-a7ef-31d91723b662%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.