[ansible-project] Re: Unreachable error

2016-06-15 Thread Alexey Vazhnov
First, check SSH connection. In your case:
ssh 127.0.0.1

On Thursday, June 16, 2016 at 5:28:39 AM UTC+5, navdeep uniyal wrote:
>
> Hi all, 
>
> I am new to ansible. I have been learning ansible using ad hoc commands as 
> well as ansible playbooks. Things were running fine until I started getting 
> errors as given below. I have no idea how to resolve these errors. Please 
> help.
>
> navdeep@ansible-master:~$ sudo ansible all -m ping -s -k
> SSH password: 
> 127.0.0.1 | UNREACHABLE! => {
> "changed": false, 
> "msg": "Authentication failure.", 
> "unreachable": true
> }
>
>
>
>
> navdeep@ansible-master:~$ sudo ansible-playbook our-playbook.yml -s -k -K
> SSH password: 
> SUDO password[defaults to SSH password]: 
>
> PLAY [local] 
> ***
>
> TASK [setup] 
> ***
> fatal: [127.0.0.1]: UNREACHABLE! => {"changed": false, "msg": 
> "Authentication failure.", "unreachable": true}
> to retry, use: --limit @our-playbook.retry
>
> PLAY RECAP 
> *
> 127.0.0.1  : ok=0changed=0unreachable=1   
>  failed=0   
>
>
>
>
>

-- 
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/00ddc361-ced8-4262-9ac6-2d7c10d53a7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] vsphere_guest module and how to configure static IP

2016-06-15 Thread Dann Bohn
Jeff,
You need to send the clone operation an customization spec in order to do 
guest customizations on a vSphere VM. This is not included in the 
vsphere_guest module. 

>From what I can tell from reading the roadmap 
(https://github.com/ansible/ansible/blob/devel/docsite/rst/roadmap/ROADMAP_2_2.rs)
 
the ansible folks would like to add such features to vsphere_guest in the 
2.2 release.

In the meantime, you can look at a module I wrote to accomplish this: 
https://github.com/whereismyjetpack/ansible_vcenter_module. It allows you 
to send specific guest customization parameters to the clone operation, the 
module is not ansibly (one of the first complaints I got), and requires 
pyvmomi instead of pysphere. I've been using this in production for a 
little over a year.. feel free to contact me if you have any questions, and 
time permitting i'll do my best to answer them. I've tested this code on 
vSphere 5.5 and 6.0.



Dann







On Wednesday, June 15, 2016 at 4:03:11 PM UTC-4, Jeff Richards wrote:
>
> Brian, I already have VMware tools installed, what options does that give 
> me?
>
> Jeff
>
> On Wednesday, June 15, 2016 at 9:06:28 AM UTC-7, Brian Coca wrote:
>>
>> sadly vmware/vcenter gives no direct way to do this, you either need to 
>> run a 'boot script' that does it or have the vmware guest tools installed.
>>
>>
>>
>>
>> -- 
>> --
>> 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/1feb834e-c4c5-447c-b15f-eae36378e040%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible collect & translate server data

2016-06-15 Thread Ansible User


Ansible newbie here with a more general question. I have a large number of 
servers that need to be re-build from scratch (no option on this). Ideally 
I would (1) pull the install & config info from the servers, (2) translate 
that into playbooks, (3) use it to build the new servers. I think (3) will 
be the easy part, but any advice on 1 & 2? 

-- 
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/2c4925f5-091f-403b-b011-1e1f83fe5df8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Unreachable error

2016-06-15 Thread navdeep uniyal
Hi all, 

I am new to ansible. I have been learning ansible using ad hoc commands as 
well as ansible playbooks. Things were running fine until I started getting 
errors as given below. I have no idea how to resolve these errors. Please 
help.

navdeep@ansible-master:~$ sudo ansible all -m ping -s -k
SSH password: 
127.0.0.1 | UNREACHABLE! => {
"changed": false, 
"msg": "Authentication failure.", 
"unreachable": true
}




navdeep@ansible-master:~$ sudo ansible-playbook our-playbook.yml -s -k -K
SSH password: 
SUDO password[defaults to SSH password]: 

PLAY [local] 
***

TASK [setup] 
***
fatal: [127.0.0.1]: UNREACHABLE! => {"changed": false, "msg": 
"Authentication failure.", "unreachable": true}
to retry, use: --limit @our-playbook.retry

PLAY RECAP 
*
127.0.0.1  : ok=0changed=0unreachable=1failed=0 
  




-- 
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/6c1f6163-c64e-408b-b847-85cd0b65b14d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Variable definition best practice

2016-06-15 Thread Mpampis Mpigkonias
Hello,

I use some fact variables in my playbook in my tasks code (I've been using 
roles). I know that they don't need to be defined in the vars part, but is 
it a good practice to do so?

I have something like:

hostname: "{{ ansible_hostname }}"
> year: "{{ ansible_date_time.year }}"
> month: "{{ ansible_date_time.month }}"
> day: "{{ ansible_date_time.day }}"
> date: "{{ ansible_date_time.date }}"
> dest_file: "/tlp_adm/recoverydata/linux/{{ year }}/{{ month }}/{{ day 
> }}/{{ hostname }}.recoverydata.{{ date }}"
>

 in vars.

while the tasks code does something like this:

- name: Ensure destination path exists
>   file: path=/tlp_adm/recoverydata/linux/{{ year }}/{{ month }}/{{ day }} 
> state=directory
> - name: Output recovery log
>   local_action: template src=tlp_recoveryData.j2 dest="{{ dest_file }}"
>

I think that defining variables like this on top makes the code a little 
bit more readable, but I don't know if it makes sense to put everything in 
variables, like for example the source path or the facts (?).

What is your opinion? What are the best practices on this?


-- 
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/30395053-a693-4dff-8909-7183dfeffa11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Nested varibbles and defined

2016-06-15 Thread Brian Coca
need to set default at every level that might be undefined.

(var1|default({})).(var2|default({})).var3 | default('FAILS')

​the same with defined

var1 is defined and var1.var2 is defined and var1.var2.var3 is defined​

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


[ansible-project] Setting up SSL for Windows Remote Nodes

2016-06-15 Thread skinnedknuckles
Control Node:

   - CentOS 7
   - Ansible 2.1
   - pywinrm version from May 19th, 2016

Remote Node:

   - Windows 7
   - Powershell 3

Here is everything I've picked up so far to get SSL working.  Please let me 
know if each of these are correct or not.

1.  I must have pywinrm installed on the management node

2.  The /etc/ansible/hosts file on the management node must have something 
like this

[windows]
computerName1
computerName2

3.  The directory /etc/ansible/group_vars must have a YAML file whos name 
matches the word in brackets above (windows in this case).  So 
/etc/ansible/group_vars/windows.yml should look something like this

ansible_user: ansibleAdmin
ansible_password: p@$$w0rd
ansible_port: 5986
ansible_connection: winrm

4.  There must be a local account with admin privileges created on each 
remote node with the same username and password as listed above.

5.  A certificate request must be created on a remote node with the IIS 
manager and submitted to my IT department using exact name as shown above 
in the windows.yml file.  The common name on the certificate request must 
be something like

ansibleAdmin.aa.bb.acme.com

6.  The certificate(s) sent back to me from the IT department must be 
imported using mmc on each remote node.

7.  Each remote node must be running powershell and have downloaded and run 
Trond 
Hindenes powershell script 

 
for enabling WinRM/PSRemoting

8.  If all of this is done correctly I should get a pong from each of my 
remote nodes when I type my win_ping request as shown below

$ansible windows -m win_ping

Is all of this correct?   Am I missing anything?

-- 
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/bf85f17d-f421-4489-8d7b-9fd6c2839362%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] vsphere_guest module and how to configure static IP

2016-06-15 Thread Jeff Richards
Brian, I already have VMware tools installed, what options does that give 
me?

Jeff

On Wednesday, June 15, 2016 at 9:06:28 AM UTC-7, Brian Coca wrote:
>
> sadly vmware/vcenter gives no direct way to do this, you either need to 
> run a 'boot script' that does it or have the vmware guest tools installed.
>
>
>
>
> -- 
> --
> 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/6400f4a5-2d86-4132-bba9-47a7e0bdaa6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Weird: Passing variables to roles

2016-06-15 Thread Trond Hindenes
>From what I can see, once a previously undefined variable has been set by a 
role, the calling playbook is unable to override it on subsequent calls.

On Wednesday, June 15, 2016 at 8:29:17 PM UTC+2, Trond Hindenes wrote:
>
> Hi, 
> I have this weird situation where a role doesn't pick up configured 
> variables, hopefully someone can help me out. 
> This is parts of my playbook:
> -   name: Deploy Elasticsearch VMs
> hosts: localhost
> tags:
> - deploy
> vars:
> os_type: Windows
> public_ip: yes
> use_max_datadisks: True
> create_network_security_group: nsg_eslogging
> create_availability_set: yes
> add_to_adhoc_group: elasticsearch
>
> roles:
> - { role: customer_deploy_azurevm, vm_name: customer-prod-es1}
> - { role: customer_deploy_azurevm, vm_name: customer-prod-es2}
>
> -   name: Deploy logstash VMs
> hosts: localhost
> tags:
> - deploy
> vars:
> os_type: Windows
> public_ip: yes
> max_data_disk_count: 2
> create_network_security_group: nsg_logstash
> create_availability_set: yes
> availability_set_name: as-customer-prod-logstash
> add_to_adhoc_group: logstash
> roles:
> - { role: customer_deploy_azurevm, vm_name: customer-prod-ls1}
> - { role: customer_deploy_azurevm, vm_name: customer-prod-ls2}
>
> The weird thing that happens is that the second play's vms don't get the 
> correct availability set (availability_set_name), but they DO get the 
> correct nsg (create_network_security_group). The customer_deploy_azurevm 
> roles works so that if "create_availability_set" is true and 
> "availability_set_name" is not set, then an autogenerated availability set 
> name will be used. This variable seems to "linger" so that the following to 
> vms get the previous auto-generated availability set name (I can see this 
> if I dump all vars before I do anything else in the role)
>
> This seems completely weird to me. Am I doing something wrong, or is this 
> a bug?
>
>

-- 
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/e647e387-dacc-47be-ba13-7d04bbc49b0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Weird: Passing variables to roles

2016-06-15 Thread Trond Hindenes
Hi, 
I have this weird situation where a role doesn't pick up configured 
variables, hopefully someone can help me out. 
This is parts of my playbook:
-   name: Deploy Elasticsearch VMs
hosts: localhost
tags:
- deploy
vars:
os_type: Windows
public_ip: yes
use_max_datadisks: True
create_network_security_group: nsg_eslogging
create_availability_set: yes
add_to_adhoc_group: elasticsearch

roles:
- { role: customer_deploy_azurevm, vm_name: customer-prod-es1}
- { role: customer_deploy_azurevm, vm_name: customer-prod-es2}

-   name: Deploy logstash VMs
hosts: localhost
tags:
- deploy
vars:
os_type: Windows
public_ip: yes
max_data_disk_count: 2
create_network_security_group: nsg_logstash
create_availability_set: yes
availability_set_name: as-customer-prod-logstash
add_to_adhoc_group: logstash
roles:
- { role: customer_deploy_azurevm, vm_name: customer-prod-ls1}
- { role: customer_deploy_azurevm, vm_name: customer-prod-ls2}

The weird thing that happens is that the second play's vms don't get the 
correct availability set (availability_set_name), but they DO get the 
correct nsg (create_network_security_group). The customer_deploy_azurevm 
roles works so that if "create_availability_set" is true and 
"availability_set_name" is not set, then an autogenerated availability set 
name will be used. This variable seems to "linger" so that the following to 
vms get the previous auto-generated availability set name (I can see this 
if I dump all vars before I do anything else in the role)

This seems completely weird to me. Am I doing something wrong, or is this a 
bug?

-- 
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/5b96b8ac-0341-46e4-bf0c-c99868330c5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible 2.1 not logging commands

2016-06-15 Thread John G
Hi,

With Ansible 2.1 the commands are not being logged to the ansible.log file. 
With ansible 1.9.4 the commands are logged. Is there a setting or a 
callback plugin to check?

System with ansible 1.9.4, rpm ansible-1.9.4-1.el7.noarch.
2016-06-15 13:33:53,312 p=6786 u=root |   
2016-06-15 13:33:53,312 p=6786 u=root |  /bin/ansible-playbook ping.yml -i 
inv/qa/hosts_ansible_testing --check
2016-06-15 13:33:53,312 p=6786 u=root |   
2016-06-15 13:33:59,919 p=6786 u=root |  PLAY [all] 
 
2016-06-15 13:33:59,921 p=6786 u=root |  TASK: [Ping systems] 
**

System with ansible 2.1.0.0, rpm ansible-2.1.0.0-1.el7.noarch.
2016-06-15 13:34:07,646 p=5690 u=root |  [DEPRECATION WARNING]: Instead of 
sudo/sudo_user, use become/become_user and make sure become_method is 'sudo' 
(default).
This feature will be removed in a future release. Deprecation warnings can 
be disabled by setting deprecation_warnings=False in ansible.cfg.
2016-06-15 13:34:07,817 p=5690 u=root |  PLAY [all] 
*
2016-06-15 13:34:07,923 p=5690 u=root |  TASK [Ping systems] 


Thanks,
John

-- 
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/a9d15d47-359d-4422-b5da-135b0c5ab6a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: More Ansible Tower - create an inventory group

2016-06-15 Thread Peter Mooshammer
Hello 

thanks for the reply,

I knew about the in-memory thing. It seems like I need to do something with 
the tower-cli in order to create a inventory.

Peter

On Wednesday, June 15, 2016 at 4:58:31 AM UTC-7, Abhishek R. wrote:
>
> You can create run-time, in-memory, ad-hoc groups using the group-by 
> module in a playbook - 
> http://docs.ansible.com/ansible/group_by_module.html.
>
> Though this wouldn't modify the actual inventory file itself. The groups 
> will be available only during the playbook run itself. Perhaps you can add 
> tasks in the playbook for updating the chosen groups in the inventory file 
> well..
>
> Regards
>
> On Tuesday, June 14, 2016 at 11:00:01 AM UTC+5:30, Peter Mooshammer wrote:
>>
>> Hello,
>>
>> Is there a way to create a new inventory group other than through the UI?
>>
>> thanks
>>
>> Peter
>>
>

-- 
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/868a458f-f27d-4102-a0c7-25dcd2ce54b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible 2.1 failing on pam_limits module

2016-06-15 Thread Brian Coca
you seem to be using a custom pam_limits module that does not have a shebang


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


Re: [ansible-project] vsphere_guest module and how to configure static IP

2016-06-15 Thread Brian Coca
sadly vmware/vcenter gives no direct way to do this, you either need to run
a 'boot script' that does it or have the vmware guest tools installed.




-- 
--
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/CACVha7edXu2pa4BaXC3%3D-38WcJh_%3D75P2euZ%3DO3%2Br6A-GZ0Jxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Conditional variables

2016-06-15 Thread Brian Coca
 file: path={{ (ssh_keygen_user == root)|ternary('/root','/home/' +
ansible_user)}}/.ssh state=directory mode=0700 owner={{ ansible_user }}
group={{ ansible_user }}



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


Re: [ansible-project] Accessing registered variables inside callback plugin

2016-06-15 Thread Brian Coca
the 'results' you get on callback methods IS the what would be in the
registered var for that task.


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


Re: [ansible-project] Re: Get Process ID of ansible-playbook within the playbook

2016-06-15 Thread Brian Coca
lookup('pipe', 'echo $PPID')

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


[ansible-project] How I can clone with ansible into specific directory without annoying git folder?

2016-06-15 Thread Andrey Vinogradov
Hi guys! I stuck on the cloning the git content without the folder itself.
I am using the task like:
git: repo=g...@bitbucket.org:project/someRepo.git dest=/var/www 
 accept_hostkey=yes version=someVersion force=yes
and I am getting the someRepo folder in /var/www, but I need the someRepo 
content without the folder itself.
I found the solution on 
http://stackoverflow.com/questions/6224626/github-clone-contents-of-a-repo-without-folder-itself
but it looks ugly and I can't use it for both repo creation and repo 
update. Is there a possibility to solve my problem with ansible git module?

-- 
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/8f7270b3-b360-47ad-b58a-8db58909a66d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Get Process ID of ansible-playbook within the playbook

2016-06-15 Thread Guillaume Nobiron
You can get the PID from the PPID shell environment variable:

>   - name: get pid of playbook
> shell: echo "$PPID"
> register: ansible_pid


Then you can use {{ansible_pid.stdout}} to get the PID value.


-- 

[image: logoVif] 
L'informatique 100% Agro www.vif.fr 
[image: VifYouTube] [image: VifTwitter] 

*Suivez l'actualité VIF sur:* 

-- 
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/e196e73c-8dde-4e6c-844b-98d23a50a7b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Another variable within a variable for jinja templates

2016-06-15 Thread Keith Poirier
With help from the google + ansible community here is what I have in my 
template that works:

{% set all_interfaces = (ansible_interfaces | difference(['lo'])) %}
{% for dev in all_interfaces %}
{% set dev_info = hostvars[inventory_hostname]['ansible_' + dev] %}
{% if dev_info.active %}
NETWORK_INTERFACE {{ dev }}
HEARTBEAT_IP  {{ dev_info.ipv4.address }}
{% endif %}
{% endfor%}



On Friday, June 10, 2016 at 2:37:51 PM UTC-4, Matt Martz wrote:
>
> You will need to use something like:
>
> {{ hostvars[inventory_hostname]["ansible_" ~ dev].ipv4.address }}
>
>
> On Fri, Jun 10, 2016 at 11:31 AM, Keith Poirier  > wrote:
>
>>
>> What I'm trying to do is get a list of active NICs on a system and build 
>> a template using what I find. The playbook looks like:
>>
>> ---
>> - name: generate Management serviceguard template file
>> shell: ip link show|grep -v lo|grep UP|awk '{print $2}'|sed s/://g
>> register: nics
>> template: src=roles/mgt/templates/sg/generic/mgt_cluster.config 
>> dest=/opt/cmcluster/conf/mgt.config
>>
>>
>> The template portion that isn't working is:
>>
>> {% for dev in nics.stdout_lines %}
>> NETWORK_INTERFACE {{ dev }}
>> HEARTBEAT_IP  {{ ansible_[ dev ].ipv4.address }}
>> {% endfor%}
>>
>>
>> The initial variable - {{ dev }} works fine but I'm having a hard time 
>> getting that variable to work within the standard ansible_eth*.ipv4.address 
>> variable. 
>>
>> I'd appreciate any thoughts on the matter.
>>
>> Keith
>>
>>
>> -- 
>> 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/da1de1c0-d2ae-4fe8-bb87-dec7173b60c8%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Matt Martz
> @sivel
> sivel.net
>

-- 
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/76d3e870-d29e-4738-afcd-0cab7c0c84fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Get Process ID of ansible-playbook within the playbook

2016-06-15 Thread 'J Hawkesworth' via Ansible Project
I have done this in a callback plugin by 

import os
pid = os.getpid()

The callback plugin code is here if that is 
helpful: 
https://github.com/jhawkesworth/ansible/commit/38b639ac1c2fae90177a87eff5611d62ff8ad00f

This would be more difficult for a task though, because a/ ansible forks so 
each host might have a different process id I think - 
see http://docs.ansible.com/ansible/intro_configuration.html#forks
Also not sure what happens when you delegate_to: localhost , although I'd 
imagine you'd still get the fork pid even then.

There might be another way around what you are trying to achieve though. 
 Sometimes I use delegate_to to run commands just on the first node in a 
cluster for example, so I know that that command will only get run once.
See 
http://docs.ansible.com/ansible/faq.html#how-do-i-access-a-variable-of-the-first-host-in-a-group
 
and http://docs.ansible.com/ansible/playbooks_delegation.html#delegation

You might be able to use the block / rescue syntax too as well - 
see http://docs.ansible.com/ansible/playbooks_blocks.html#error-handling

Hope this helps,

Jon



On Tuesday, June 14, 2016 at 11:24:46 PM UTC+1, Rajas Pimpalwadkar wrote:
>
> I want to add locking around some part of a playbook. For this I need to 
> get the process id of ansible-playbook that has started the task that I am 
> currently running.
> How do I get process id of ansible-playbook that the current task is part 
> of? I cannot use grep reliable because there could be multiple 
> ansible-playbook processes running.
>
>

-- 
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/cdeadf8c-b479-4eb5-9c23-0e209bf375c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Lineinfile append at EOF

2016-06-15 Thread Abhishek R.
You should probably try using {{ redis.stdout }}. Registered variables are 
not inherently strings, unlike extra_vars.

Regards

On Tuesday, June 14, 2016 at 11:42:29 AM UTC+5:30, Mona Gopal wrote:
>
> Hi All,
>
>  I figured out that the below works to append to a file,
>
> - name: Write redis details to file
>   local_action: lineinfile dest={{ third_party_dest_path }} line=redis 
> state=present create=yes
>
> However, i am unable to append the registered variable value to the file
>
> - name: Write redis details to file
>   local_action: lineinfile dest={{ third_party_dest_path }} *line="{{ 
> redis }}"* state=present create=yes
>
>
>
>
> On Tuesday, June 14, 2016 at 10:36:33 AM UTC+5:30, Mona Gopal wrote:
>>
>> Hi all,
>>
>> I am trying to use the lineinfile module to append  some of the software 
>> details to a file. 
>> I don't want to match to any regexp, but just insert every software 
>> details at the EOF.
>>
>>
>> Below is the piece of code.
>>
>> - name: Collect python details
>>   action: get_python_details 
>>   register: python
>>
>> - name: Write registered variable to file
>>   local_action: lineinfile dest={{ third_party_dest_path }}  line={{ 
>> python }} regexp="" insertafter=EOF state=present create=yes
>>
>> Have also tried giving regexp="^$", regexp="^\s*$" as well to match to 
>> an empty line, but throws the below error.
>>
>> Error:
>>
>> An exception occurred during task execution. The full traceback is:
>> Traceback (most recent call last):
>>   File 
>> "/root/.ansible/tmp/ansible-tmp-1465888759.41-82910653497853/lineinfile", 
>> line 2540, in 
>> main()
>>   File 
>> "/root/.ansible/tmp/ansible-tmp-1465888759.41-82910653497853/lineinfile", 
>> line 371, in main
>> ins_aft, ins_bef, create, backup, backrefs)
>>   File 
>> "/root/.ansible/tmp/ansible-tmp-1465888759.41-82910653497853/lineinfile", 
>> line 266, in present
>> lines.append(line + os.linesep)
>> TypeError: unsupported operand type(s) for +: 'dict' and 'str'
>>
>> fatal: [172.19.3.60 -> localhost]: FAILED! => {"changed": false, "failed": 
>> true, "invocation": {"module_name": "lineinfile"}, "parsed": false}
>>
>>
>> Kindly help on how to go about appending to EOF without matching to any 
>> regexp.
>>
>>
>> Thanks in advance,
>>
>> Mona 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/6a303005-6374-4681-b7be-87509bf8ddd9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: More Ansible Tower - create an inventory group

2016-06-15 Thread Abhishek R.
You can create run-time, in-memory, ad-hoc groups using the group-by module 
in a playbook - http://docs.ansible.com/ansible/group_by_module.html.

Though this wouldn't modify the actual inventory file itself. The groups 
will be available only during the playbook run itself. Perhaps you can add 
tasks in the playbook for updating the chosen groups in the inventory file 
well..

Regards

On Tuesday, June 14, 2016 at 11:00:01 AM UTC+5:30, Peter Mooshammer wrote:
>
> Hello,
>
> Is there a way to create a new inventory group other than through the UI?
>
> thanks
>
> Peter
>

-- 
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/44402a4c-7e73-4e1b-ab86-8d8726f00ed0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Get Process ID of ansible-playbook within the playbook

2016-06-15 Thread Abhishek R.
The actual process record includes the name/path of the playbook being run. 
You should be able to use piped greps over ps/pgrep to get the current 
playbook.

-- 
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/6de8a0bd-3e5e-4129-b62a-4516cb9f6ea5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Accessing registered variables inside callback plugin

2016-06-15 Thread Abhishek R.
Hi,

I have a simple playbook that registers some variables. And I have a mail 
callback plugin that sends out an email if a playbook run fails 
(runner_on_failed). How do I access the value of a registered variable from 
within the callback plugin, with the purpose of sending that value across 
in the email? 

I did see various discussions and examples of access hostvars and group 
vars from within the callback module. But didn't really find an example of 
accessing a registered variable.

Any examples or suggestions will be helpful. Thanks in advance.

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/e14644f3-20fb-4ee0-a81c-7def1096d4c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.