[ansible-project] install help from source

2017-07-26 Thread Imam Toufique
Hi, 

I am new to Ansible.  I am looking into using ansible, but I don't want to 
install this from rpm or deb packages. I was trying to install from source, 
but I can't seem to find out the exact process of installing it in a 
different path other then /usr/local/bin (I guess it is the default? ) .  

is there any documentation on how to install this from source?  i found 
this 
link 
http://docs.ansible.com/ansible/latest/intro_installation.html#running-from-source
 
, but it does not explain how to install the tool in a different location 
other then /usr/bin or /usr/local/bin.

i downloaded the latest bits from the release area.  

Any help would be very much appreciated! 

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/6ce4287d-5644-41de-87dd-8e773987f322%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] ansible with forks > 1 doesn't work using ansible_ssh_host/ansible_ssh_port

2017-07-26 Thread Sureshkumar Kaliannan
Hi,

We are tunneling ssh through websocket..so the inventory looks something 
like this..

[nodes]
host1  ansible_ssh_host=localhost ansible_ssh_port=26532 
host2  ansible_ssh_host=localhost ansible_ssh_port=

[admin@nsm-dev2-suresh ~]$ ansible -vv -m ping nodes
Using /etc/ansible/ansible.cfg as config file
META: ran handlers
host2 | SUCCESS => {
"changed": false, 
"ping": "pong"
}
host1 | UNREACHABLE! => {
"changed": false, 
"msg": "Failed to connect to the host via ssh: Connection timed out 
during banner exchange\r\n", 
"unreachable": true
}
META: ran handlers
META: ran handlers

Manual ssh always works..and also keeping the fork=1 always works.


Always, the firsthost works fine and subsequent hosts fail. 
When the same command is tried again, firsthost uses the persistent 
connection and goes through and the second host establishes the new session 
and all subsequent hosts will fail. 
And the next try, first two hosts which uses persistent connection works 
fine, 3rd establishes new ssh session, and all subsequent hosts will fail.


So if I disable persistent connection by removing ControlPersist=, always 
only the firsthost works, and all subsequent hosts fail.

I tried increasing the timeout but that doesn't help.

Not sure where to start the debugging..- option all i get is, 

host1 | UNREACHABLE! => {
"changed": false, 
"msg": "Failed to connect to the host via ssh: OpenSSH_6.6.1, OpenSSL 
1.0.1e-fips 11 Feb 2013\r\ndebug1: Reading configuration data 
/etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 56: Applying 
options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug1: 
Control socket \"/home/admin/.ansible/cp/b9ebd9b1c9\" does not 
exist\r\ndebug2: ssh_connect: needpriv 0\r\ndebug1: Connecting to localhost 
[127.0.0.1] port 26532.\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug1: fd 3 
clearing O_NONBLOCK\r\ndebug1: Connection established.\r\ndebug3: timeout: 
1 ms remain after connect\r\ndebug3: Incorrect RSA1 
identifier\r\ndebug3: Could not load \"/home/admin/.ssh/id_rsa\" as a RSA1 
public key\r\ndebug1: identity file /home/admin/.ssh/id_rsa type 
1\r\ndebug1: identity file /home/admin/.ssh/id_rsa-cert type -1\r\ndebug1: 
identity file /home/admin/.ssh/id_dsa type -1\r\ndebug1: identity file 
/home/admin/.ssh/id_dsa-cert type -1\r\ndebug1: identity file 
/home/admin/.ssh/id_ecdsa type -1\r\ndebug1: identity file 
/home/admin/.ssh/id_ecdsa-cert type -1\r\ndebug1: identity file 
/home/admin/.ssh/id_ed25519 type -1\r\ndebug1: identity file 
/home/admin/.ssh/id_ed25519-cert type -1\r\ndebug1: Enabling compatibility 
mode for protocol 2.0\r\ndebug1: Local version string 
SSH-2.0-OpenSSH_6.6.1\r\nConnection 
timed out during banner exchange\r\n", 
"unreachable": true
}

All are CentOS 7.3 hosts, with ansible 2.3.1.0 (even the earlier 2.2 
version has the same problem)

Any pointers to debug this problem ??

thanks
Suresh

-- 
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/c1a0e383-803b-4667-b9cf-5a85855b8099%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] ANSIBLE: how to append a string at the end of a file

2017-07-26 Thread Vijay Misra

  Hi ,

   I am trying to use ansible as a test tool. at the end of each 
sucess/faiure i want to append a string at the end of a file and this file 
can be used as a test report.
i Have tried this code but it did not log anything in the file.

- debug: msg="HPQC Create snapshot of a vGPU VM on ESX"
  when: taskresult|succeeded
- debug: msg="HPQC Failed Create snapshot of a vGPU VM on ESX"
  when: taskresult|failed


- shell: echo "HPQC Passed Create snapshot of a vGPU VM on ESX" >> results.txt
  when: taskresult|succeeded
- shell: echo "HPQC Failed Create snapshot of a vGPU VM on ESX" >> results.txt
  when: taskresult|failed


  when i run with - switch, I get the following output but nothing is 
appended in the file locataed at /etc/ansible/ directoery( I am running 
playbook from /etc/ansible directory)

 
changed: [] => {
"changed": true, 
"cmd": "echo \"HPQC Passed Create snapshot of a vGPU VM on ESX\" >> 
results.txt", 
"delta": "0:00:00.017046", 
"end": "2017-07-27 00:07:14.100974", 
"invocation": {
"module_args": {
"_raw_params": "echo \"HPQC Passed Create snapshot of a vGPU VM on 
ESX\" >> results.txt", 
"_uses_shell": true, 
"chdir": null, 
"creates": null, 
"executable": null, 
"removes": null, 
"warn": true
}
}, 
"rc": 0, 
"start": "2017-07-27 00:07:14.083928", 
"stderr": "", 
"stderr_lines": [], 
"stdout": "", 
"stdout_lines": []
}

TASK [ESX_VM_SnapRestore : command] 

task path: /etc/ansible/roles/ESX_VM_SnapRestore/tasks/main.yml:41
skipping: [1] => {
"changed": false, 
"skip_reason": "Conditional result was False", 
"skipped": true
}

Thanks for your help.

-VM

-- 
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/27ac4a14-15fc-4ced-85b1-4abe7a8236ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Storing IP address of First node (Control Node) in variable

2017-07-26 Thread Pshem Kowalczyk
Ansible runs an implicit loop for all the devices. If you access a variable
in the 'regular' way you can only see variabels/facts set for the current
device. Variables/facts set for other devices (that the loop already ran
through) can be accessed via the 'hostvars' variable.

If you know that you want the IP of the first host in the group you might
try something like this (not tested):

- set fact:
my_IP: "{{
hostvars[hostvars[hostvars.keys()[0]]['groups']['webservers'][0]]['ansible_facts']['ansible_default_ipv4']['address]
}}"

how this (should) work:
hostvars.keys()[0] - gets you the name of the first device in the inventory
(for this play), all devices share group info
['groups']['webservers'][0] - gets you the name of the first host in that
group

so this turns in to
hostvars['10.10.10.1']['ansible_facts']['ansible_default_ipv4']['address']
which should contain the info you're after.

There are probably some simpler ways of achieving that as well.

kind regards
Pshem



On Thu, 27 Jul 2017 at 08:11 Homayoun Najafizadeh 
wrote:

> It might be a dumb question but I can't get this to work. I want to print
> IP address of my control node in all nodes.
>
> Lets say I have this in hosts:
> [webservers]
> 10.10.10.1
> 10.10.10.2
> 10.10.10.3
>
>
> When I run my "ansible-playbook -s myCode.yml" on 10.10.10.1 I want to see
> my debug line says:
>
> ok: [10.10.10.1] => var = 10.10.10.1
> ok: [10.10.10.2] => var = 10.10.10.1
> ok: [10.10.10.3] => var = 10.10.10.1
>
>
>
> I have done something like this but didn't work:
>
>- set_fact:
> myIP: "{{ ansible_all_ipv4_addresses.split[0] }}"
>  when: inventory_hostname == groups["serserver"][0]
>
> This actually prints: 10.10.10.1   10.10.10.2   10.10.10.3
>
>
>
>
> Thanks in advance.
>
> --
> 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/e5dd318a-ee88-4d29-a12c-12cbc1ea3810%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [ansible-project] how to debug ansible seg vault ?

2017-07-26 Thread Mike C
thanks for the info, ill give it a go.
Im not convinced either that the seg fault is ansibles, but i need more 
info to see a stack the very least.



On Wednesday, July 26, 2017 at 10:08:46 PM UTC+1, Adrian Likins wrote:
>
>
> Can you reproduce the segfault? 
>
> Can try running it under gdb:
>
> # 'bin/ansible-playbook' or the path to you ansible-playbook install 
> (`which ansible-playbook`)
> gdb --batch -ex run  --args python bin/ansible-playbook -vvv 
> your_playbook.yml
>
> But maybe easier to use catchsegv to grab a stack trace
>
>   catchsegv ansible-playbook -vvv your_playbook.yml
>
> Since that log message points to a segfault in python, you likely need to 
> install the debuginfo for
> python first, something like:
>
>   sudo apt-get install python2.7-dbg
>
> Though the segfault is likely coming from a python C extension and not 
> ansible
> itself...
>
>
>
> On Wed, Jul 26, 2017 at 6:50 AM, Mike C > 
> wrote:
>
>> im getting a seg fault when im running my ansible. Is there a way to turn 
>> on more debugging or anything that can help me find out the source ?
>>
>> My `/var/log/syslog` has entries like this
>>
>> ```
>> Jul 26 10:47:26 ubuntu-xenial kernel: [  497.822661] 
>> ansible-playboo[13890]: segfault at a9 ip 004a7ee4 sp 
>> 7ffdabc1b128 error 4 in python2.7[40+2ea000]
>> ```
>>
>> I've tried `-` but no luck there.
>>
>> Cheers
>>
>> -- 
>> 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/8e70a592-86bd-4cee-8f9f-4736fad8ed95%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/f5bac64c-b148-412f-a506-5fcacb4d029c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Using Pathword Authentication to run a Playbook

2017-07-26 Thread Adrian Likins
ansible-playbook isnt really the right tool for writing interactive
tooling. There is some very limited support for it
but it is not a good approach.

Some of the previous mentioned suggestions  (password protected prod only
ssh keys and ssh-agent...) will be
more useful in the long run. Or using a wrapper script to handle the
interactivity if required.

But avoid trying to use ansible as an interactive tool.


On Tue, Jul 25, 2017 at 7:29 AM, JS  wrote:

> Hi Kai
>
> Thanks for that - it worked like a charm on the CLI!
>
> - pre_tasks:
>- pause:
>prompt: "You are running against production. What is the
> magic word?"
>  register: result
>  when: env == 'prod'
>
>- fail:
>msg: "Aborting, wrong magic."
>when: result.user_input | default('') != 'answerable' and env
> == 'prod'
>
>
> I've integrated the playbook with Jenkins - so it doesn't work on there. I
> get the following error:  [WARNING]: Not waiting from prompt as stdin is
> not interactive
>
> But I suppose that's not a problem as we can run DEV/UAT via Jenkins (GUI)
> and the PROD environment via CLI.
>
> --
> 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/8bfcbdfc-a669-4f62-af4a-2b57fa05b30c%40googlegroups.
> com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAOJNLf9-V%3D%2B4BSS5DXr92HYtofkFvtU587i3ZTiZbyNLq%3Dq_XQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Role included multiple times only seems to run once

2017-07-26 Thread Matthew Rathbone
Hey Adrian -- thanks for your response!

I did about an hour of reading and playing around with dependencies and I
figured it out:

I needed to add allow_duplicates: yes to the role I was depending on, not
my role. So I forked the redis-server role, added the statement, and it
works!

Thanks for helping to point me in the right direction.

Matthew

On Wed, Jul 26, 2017 at 4:20 PM, Adrian Likins  wrote:

> http://docs.ansible.com/ansible/latest/playbooks_
> roles.html#role-dependencies
>
>  "Roles dependencies are always executed before the role that includes
> them, and are recursive. By default, roles can also only be added as a
> dependency once - if another role also lists it as a dependency it will not
> be run again. This behavior can be overridden by adding allow_duplicates:
> yes to the meta/main.yml file. For example, a role named ‘car’ could add
> a role named ‘wheel’ to its dependencies as follows:"
>
> Does 'allow_duplictes: yes' work?"
>
> On Wed, Jul 26, 2017 at 4:47 PM, Matthew Rathbone  wrote:
>
>> Hey guys,
>>
>> So I have a project setup in the following way:
>>
>> - requiring an external redis-server role
>> - my own role called redis-cluster-shard that uses redis-server as a
>> dependency
>> - a playbook that applies this role twice to the same node. Like this:
>>
>>
>> - role: "rds-cache-shard"
>>   rds_port: 7000
>> - role: "rds-cache-shard"
>>   rds_port: 7001
>>
>>
>>
>> The way a redis install is created is through the dependency in
>> meta/main.ytml, which looks like this:
>>
>>
>> dependencies:
>>   - role: redis-server
>> redis_service_name: "rds_shard_{{rds_port}}"
>> redis_logfile: "/var/log/rds_shard_{{rds_port}}.log"
>> redis_clustermode_enabled: "yes"
>> redis_port: "{{rds_port|int}}"
>> redis_save:
>>   - 3600 1
>>
>>
>>
>>
>> The problem I'm having is that only one redis shard is created. IE the
>> dependency only runs once, on the first rds-cache-shard include.
>>
>> Am I doing something wrong? I'd expect the dependency tasks to run each
>> and every time a role is included, especially as I'm scoping it with
>> variables (rds_port).
>>
>>
>> --
>> 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/ms
>> gid/ansible-project/91d394a4-8a40-413e-802e-978117a30929%
>> 40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/ansible-project/W2WNjA0altE/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CAOJNLf8GzeOniCL_P%2Bbir3xeruKj_FYuPYs%
> 2BVK56xMaOjUWg9A%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Matthew Rathbone*
VP of Engineering


<+(214)+308-2245>(214) 308-2245
2556 Elm St, Dallas, TX 75226
kickbox.io
 
 

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


Re: [ansible-project] Role included multiple times only seems to run once

2017-07-26 Thread Adrian Likins
http://docs.ansible.com/ansible/latest/playbooks_roles.html#role-dependencies

 "Roles dependencies are always executed before the role that includes
them, and are recursive. By default, roles can also only be added as a
dependency once - if another role also lists it as a dependency it will not
be run again. This behavior can be overridden by adding allow_duplicates:
yes to the meta/main.yml file. For example, a role named ‘car’ could add a
role named ‘wheel’ to its dependencies as follows:"

Does 'allow_duplictes: yes' work?"

On Wed, Jul 26, 2017 at 4:47 PM, Matthew Rathbone  wrote:

> Hey guys,
>
> So I have a project setup in the following way:
>
> - requiring an external redis-server role
> - my own role called redis-cluster-shard that uses redis-server as a
> dependency
> - a playbook that applies this role twice to the same node. Like this:
>
>
> - role: "rds-cache-shard"
>   rds_port: 7000
> - role: "rds-cache-shard"
>   rds_port: 7001
>
>
>
> The way a redis install is created is through the dependency in
> meta/main.ytml, which looks like this:
>
>
> dependencies:
>   - role: redis-server
> redis_service_name: "rds_shard_{{rds_port}}"
> redis_logfile: "/var/log/rds_shard_{{rds_port}}.log"
> redis_clustermode_enabled: "yes"
> redis_port: "{{rds_port|int}}"
> redis_save:
>   - 3600 1
>
>
>
>
> The problem I'm having is that only one redis shard is created. IE the
> dependency only runs once, on the first rds-cache-shard include.
>
> Am I doing something wrong? I'd expect the dependency tasks to run each
> and every time a role is included, especially as I'm scoping it with
> variables (rds_port).
>
>
> --
> 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/91d394a4-8a40-413e-802e-978117a30929%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [ansible-project] how to debug ansible seg vault ?

2017-07-26 Thread Adrian Likins
Can you reproduce the segfault?

Can try running it under gdb:

# 'bin/ansible-playbook' or the path to you ansible-playbook install
(`which ansible-playbook`)
gdb --batch -ex run  --args python bin/ansible-playbook -vvv
your_playbook.yml

But maybe easier to use catchsegv to grab a stack trace

  catchsegv ansible-playbook -vvv your_playbook.yml

Since that log message points to a segfault in python, you likely need to
install the debuginfo for
python first, something like:

  sudo apt-get install python2.7-dbg

Though the segfault is likely coming from a python C extension and not
ansible
itself...



On Wed, Jul 26, 2017 at 6:50 AM, Mike C  wrote:

> im getting a seg fault when im running my ansible. Is there a way to turn
> on more debugging or anything that can help me find out the source ?
>
> My `/var/log/syslog` has entries like this
>
> ```
> Jul 26 10:47:26 ubuntu-xenial kernel: [  497.822661]
> ansible-playboo[13890]: segfault at a9 ip 004a7ee4 sp
> 7ffdabc1b128 error 4 in python2.7[40+2ea000]
> ```
>
> I've tried `-` but no luck there.
>
> Cheers
>
> --
> 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/8e70a592-86bd-4cee-8f9f-4736fad8ed95%40googlegroups.
> com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [ansible-project] parsing output from json

2017-07-26 Thread akku
The idea is to delete the file..
I need the formatted output, because my associated application is expecting 
such an input from ansible..
thanks for the info..

On Wednesday, July 26, 2017 at 6:15:01 PM UTC+5:30, Kai Stian Olstad wrote:
>
> On 26.07.2017 14:03, akku wrote: 
> > yes... with this it prints the path and size along with the whole 
> > output. 
> >  but  i need only the parsed output. 
>
> You don't say what you are going to use this for. 
> If you would like it in a file, use the template module. 
>
> If you would like to have it displayed nice on the screen you are 
> probably using the wrong tool. 
> Ansible is not a reporting tool but a configuration management tool. 
> But you could write your one callback plugin to make the output the way 
> you want it to be. 
>
> -- 
> Kai Stian Olstad 
>

-- 
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/1f68c043-fba2-4bbd-9d54-f9ea9c33c495%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Role included multiple times only seems to run once

2017-07-26 Thread Matthew Rathbone
Hey guys,

So I have a project setup in the following way:

- requiring an external redis-server role
- my own role called redis-cluster-shard that uses redis-server as a 
dependency
- a playbook that applies this role twice to the same node. Like this:


- role: "rds-cache-shard"
  rds_port: 7000
- role: "rds-cache-shard"
  rds_port: 7001

 

The way a redis install is created is through the dependency in 
meta/main.ytml, which looks like this:


dependencies:
  - role: redis-server
redis_service_name: "rds_shard_{{rds_port}}"
redis_logfile: "/var/log/rds_shard_{{rds_port}}.log"
redis_clustermode_enabled: "yes"
redis_port: "{{rds_port|int}}"
redis_save:
  - 3600 1




The problem I'm having is that only one redis shard is created. IE the 
dependency only runs once, on the first rds-cache-shard include.

Am I doing something wrong? I'd expect the dependency tasks to run each and 
every time a role is included, especially as I'm scoping it with variables 
(rds_port).


-- 
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/91d394a4-8a40-413e-802e-978117a30929%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Storing IP address of First node (Control Node) in variable

2017-07-26 Thread Homayoun Najafizadeh
It might be a dumb question but I can't get this to work. I want to print 
IP address of my control node in all nodes.

Lets say I have this in hosts:
[webservers]
10.10.10.1
10.10.10.2
10.10.10.3


When I run my "ansible-playbook -s myCode.yml" on 10.10.10.1 I want to see 
my debug line says: 

ok: [10.10.10.1] => var = 10.10.10.1 
ok: [10.10.10.2] => var = 10.10.10.1  
ok: [10.10.10.3] => var = 10.10.10.1



I have done something like this but didn't work:

   - set_fact:
myIP: "{{ ansible_all_ipv4_addresses.split[0] }}"
 when: inventory_hostname == groups["serserver"][0]

This actually prints: 10.10.10.1   10.10.10.2   10.10.10.3




Thanks in advance.

-- 
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/e5dd318a-ee88-4d29-a12c-12cbc1ea3810%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Best practice/way for variables to be used in template?

2017-07-26 Thread Mike Eriksson
Hi Branko,

Yeah, I stumbled onto host_vars during my trial and error approach so
that's where it all ended up.

Many thanks for getting back to me - confirming my conclusion/finding.

Cheers, Mike

On Wed, Jul 26, 2017 at 8:58 PM Branko Majic  wrote:

> On Fri, 21 Jul 2017 11:28:05 +
> Mike Eriksson  wrote:
>
> > All,
> >
> > I'm after some advice here on the best way of getting a template file
> > populated with one or more network ranges based on the host the file
> > is copied onto.
>
> Have you considered using host_vars/group_vars to define the ranges?
> Since this sounds like rather natural place to set these values at
> (allowing you to more easily reconfigure as needed without touching
> role internals).
>
> Best regards
>
> --
> Branko Majic
> XMPP: bra...@majic.rs
> Please use only Free formats when sending attachments to me.
>
> Бранко Мајић
> XMPP: bra...@majic.rs
> Молим вас да додатке шаљете искључиво у слободним форматима.
>
> --
> 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/20170726215911.31c018c9%40majic.rs
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [ansible-project] Best practice/way for variables to be used in template?

2017-07-26 Thread Branko Majic
On Fri, 21 Jul 2017 11:28:05 +
Mike Eriksson  wrote:

> All,
> 
> I'm after some advice here on the best way of getting a template file
> populated with one or more network ranges based on the host the file
> is copied onto.

Have you considered using host_vars/group_vars to define the ranges?
Since this sounds like rather natural place to set these values at
(allowing you to more easily reconfigure as needed without touching
role internals).

Best regards

-- 
Branko Majic
XMPP: bra...@majic.rs
Please use only Free formats when sending attachments to me.

Бранко Мајић
XMPP: bra...@majic.rs
Молим вас да додатке шаљете искључиво у слободним форматима.

-- 
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/20170726215911.31c018c9%40majic.rs.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] gathering facts on network devices

2017-07-26 Thread Kai Stian Olstad

On 26. juli 2017 20:58, Andrew Meyer wrote:

Ok now i'm getting this -

{"failed": true, "msg": "the field 'args' has an invalid value, which
appears to include a variable that is undefined. The error was: 'password'
is undefined\n\nThe error appears to have been in


It says password is undefined.

Since you are using the variable password you need to set in some how in 
you play, extra_vars, inventory or some other place you cat set 
variables in Ansible.



--
Kai Stian Olstad

--
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/a3ffbb95-7661-93b1-6e85-721e38e48369%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] gathering facts on network devices

2017-07-26 Thread Andrew Meyer
Ok now i'm getting this -

{"failed": true, "msg": "the field 'args' has an invalid value, which
appears to include a variable that is undefined. The error was: 'password'
is undefined\n\nThe error appears to have been in
'/home/andrew.meyer/playbooks/asa-showrun.yml': line 7, column 5, but
may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe
offending line appears to be:\n\n  tasks:\n  - name:\n^ here\n"}






Please remember to reply to all if there are multiple recipients.

Andrew Meyer
andrewm...@gmail.com
ame...@tsg2.com
314-266-4837

On Wed, Jul 26, 2017 at 1:54 PM, Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On 26. juli 2017 20:45, Andrew Meyer wrote:
>
>> So I figured that out.  But now i'm not able to connect to any of the
>> network devices.
>>
>> All of them are showing unreachable when running ansible-playbook with
>> --check.
>>
>> Here is my config:
>>
>>   cat asa-showrun.yml
>> ---
>> - hosts: "cisco-fw-ip"
>>
>
> 
>
>
>> PLAY [cisco-fw-ip]
>> 
>> **
>>
>> TASK [Gathering Facts]
>> 
>> **
>> fatal: []: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to
>> the host via ssh: Permission denied (publickey,password).\r\n",
>> "unreachable": true}
>>
> You can't use ssh directly or gather facts against most network devices as
> they do not have python install.
>
> To make it work add connection and gather_facts as shown bellow.
>
> - hosts: cisco-fw-ip
>   connection: local
>   gather_facts: false
>
>
> --
> Kai Stian Olstad
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/to
> pic/ansible-project/mIo1cOaimrU/unsubscribe.
> To unsubscribe from this group and all its topics, 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/ms
> gid/ansible-project/11a37851-b238-0e61-dd3b-720c6e820df6%40olstad.com.
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [ansible-project] gathering facts on network devices

2017-07-26 Thread Kai Stian Olstad

On 26. juli 2017 20:45, Andrew Meyer wrote:

So I figured that out.  But now i'm not able to connect to any of the
network devices.

All of them are showing unreachable when running ansible-playbook with
--check.

Here is my config:

  cat asa-showrun.yml
---
- hosts: "cisco-fw-ip"






PLAY [cisco-fw-ip]
**

TASK [Gathering Facts]
**
fatal: []: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to
the host via ssh: Permission denied (publickey,password).\r\n",
"unreachable": true}
You can't use ssh directly or gather facts against most network devices 
as they do not have python install.


To make it work add connection and gather_facts as shown bellow.

- hosts: cisco-fw-ip
  connection: local
  gather_facts: false


--
Kai Stian Olstad

--
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/11a37851-b238-0e61-dd3b-720c6e820df6%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Small Example for Reading from CSV-File for the creation of new user

2017-07-26 Thread Daniel JD
Hey Dan,

your current csv file doesn't really looks like a csv file :D The item 
variable which you are refering to is the key which jinja will use to give 
you the right csv- row. I am guessing that there will be some more values 
than the name in the future, so you could iterate over the first column 
with "with_lines" and use the lookup feature to get the other values. 
Like this

tasks:
  - name:  Add- User Task
user:
  name: "{{ item.split()[0] }}"
  uid: " {{ lookup('csvfile', item.split(',')[0] + 'file=user.csv 
delimeter=, col=1') }}" # Btw. col=1 is the default
  home: "{{ lookup('csvfile', item.split(',')[0] + 'file=user.csv 
delimeter=, col=2') }}
with_lines: cat user.csv


And your csvfile could look like this:

user.csv:
jdoe,1000,/home/jdoe
jkirk,1001,/home/jkirk
bwillis,1002,/home/bwillis
Am Mittwoch, 26. Juli 2017 18:04:45 UTC+2 schrieb Dan Steffen:
>
> Hello,
>
> maybe I am just blind but I spend today 2 hours to found out how to read 
> from a CSV to create User at the moment I have something like
>
> - hosts: all
>   user:
> name="{{ lookup('csvfile', 'item file=user.csv delimiter=, col=0') }}"
>
>
>
> and a CSV-File that looks like
>
> jdoe
> jkirk
> bwillis
>
>
>
> I already know that I have to declare the "item" Variable so I can iterate 
> through the user.csv but I don't can figured out how, maybe someone here 
> can give me a little how to define the item-Variable I would very thanksful
> best regards
> Dan
>

-- 
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/28a83613-ccba-47e7-b9a6-fd3ada9cfce7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] gathering facts on network devices

2017-07-26 Thread Andrew Meyer
So I figured that out.  But now i'm not able to connect to any of the
network devices.

All of them are showing unreachable when running ansible-playbook with
--check.

Here is my config:

 cat asa-showrun.yml
---
- hosts: "cisco-fw-ip"

  tasks:
  - name: sho run
set_fact:
  cli:
host: "{{ cisco-fw-ip }}"
username: "rancid"
password: "{{ password }}"
authorize: yes
auth_pass: "{{ password }}"
transport: cli

  - asa_command:
  commands:
- show version
  provider: "{{ cli }}"

  - asa_command:
  commands:
- show run
- show memory
  provider: "{{ cli }}"

  - asa_command:
  commands:
- show version
  provider: "{{ cli }}"
  context: system

Here is my output:

ansible-playbook asa-showrun.yml --check

PLAY [cisco-fw-ip]
**

TASK [Gathering Facts]
**
fatal: []: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to
the host via ssh: Permission denied (publickey,password).\r\n",
"unreachable": true}
fatal: []: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to
the host via ssh: Permission denied (password).\r\n", "unreachable": true}
fatal: []: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to
the host via ssh: Permission denied (password).\r\n", "unreachable": true}
fatal: []: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to
the host via ssh: Permission denied (publickey,password).\r\n",
"unreachable": true}
fatal: []: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to
the host via ssh: Permission denied (publickey,password).\r\n",
"unreachable": true}
fatal: []: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to
the host via ssh: Connection timed out during banner exchange\r\n",
"unreachable": true}
fatal: []: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to
the host via ssh: Connection timed out during banner exchange\r\n",
"unreachable": true}
fatal: []: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to
the host via ssh: Connection timed out during banner exchange\r\n",
"unreachable": true}





Please remember to reply to all if there are multiple recipients.

Andrew Meyer
andrewm...@gmail.com
ame...@tsg2.com
314-266-4837

On Wed, Jul 26, 2017 at 1:28 PM, Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On 26. juli 2017 17:09, Andrew Meyer wrote:
>
>> I seem to be having some issues making this playbook work.  I want to just
>> do a show run on all my cisco devices, but it keeps throwing errors about
>> the '- vars:' or something else.  I am on the latest version.
>>   rpm -qa|grep -i ansible
>> ansible-inventory-grapher-2.3.2-1.el7.noarch
>> ansible-2.3.1.0-1.el7.noarch
>> ansible-review-0.13.0-2.el7.noarch
>> ansible-openstack-modules-0-20140902git79d751a.el7.noarch
>> ansible-lint-3.4.12-1.el7.noarch
>> ansible-doc-2.3.1.0-1.el7.noarch
>>
>>
>> - vars:
>>hosts: cisco-fw
>>
> >  cli:
>
> You have them in the wrong order, it should be this way
>
> - hosts: cisco-fw
>   vars:
> cli:
>
> --
> Kai Stian Olstad
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/to
> pic/ansible-project/mIo1cOaimrU/unsubscribe.
> To unsubscribe from this group and all its topics, 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/ms
> gid/ansible-project/fe46bf8b-7bf4-ee58-af9c-fa7f06b9413e%40olstad.com.
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [ansible-project] Small Example for Reading from CSV-File for the creation of new user

2017-07-26 Thread Kai Stian Olstad

On 26. juli 2017 18:04, 'Dan Steffen' via Ansible Project wrote:

maybe I am just blind but I spend today 2 hours to found out how to read
from a CSV to create User at the moment I have something like

- hosts: all
  user:
name="{{ lookup('csvfile', 'item file=user.csv delimiter=, col=0') }}"


This is not a correct start of a play, you are missing tasks: and a dash 
to indicate a list.


- hosts: all
  tasks:
- user:
name=...



and a CSV-File that looks like

jdoe
jkirk
bwillis


This is not a Comma Separated Value file.
File like this one can be read by with_lines.

- debug: msg="The user is {{ item }}"
  with_lines: cat user.csv

--
Kai Stian Olstad

--
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/a62ee610-9483-be33-346f-e3c15a0eb192%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Getting a Column value from row

2017-07-26 Thread Vijay Misra
Awesome Kai & Jean ! it worked when i used the shell command. :)
Lot of thanks to you guys!

ASK [ESX_VM_SnapRestore : Get the VM id of the powered ON VM]
*
changed: []

TASK [ESX_VM_SnapRestore : debug]
**
ok: [] => {
"changed": false,
"ouputvmid": {
"changed": true,
"cmd": "vim-cmd vmsvc/getallvms | grep 'myvgpu_clone2' | cut -d ' '
-f 1",
"delta": "0:00:00.464921",
"end": "2017-07-26 18:34:12.646298",
"rc": 0,
"start": "2017-07-26 18:34:12.181377",
"stderr": "",
"stderr_lines": [],
"stdout": "51",
"stdout_lines": [
"51"
]
}
}

TASK [ESX_VM_SnapRestore : Create snapshot of a vGPU VM]
***
changed: ]



On Wed, Jul 26, 2017 at 11:23 AM, Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On 26. juli 2017 19:50, Vijay Misra wrote:
>
>> Thanks Kai for your quick response !
>> Here is my output , problem is it does not extract the VMID but outputs
>> the
>> whole string. I intend to just get the VMID.
>>
>
> I forgot that command doesn't allow pipe, so as James suggested, use the
> shell module. You can also use the raw module.
>
> - name: Get the VM id of the powered ON VM
>   shell: vim-cmd vmsvc/getallvms | grep '{{guest_name}}' | cut -d' ' -f1
>   register: ouputvmid
>
> or
>
> - name: Get the VM id of the powered ON VM
>   raw: vim-cmd vmsvc/getallvms | grep '{{guest_name}}' | cut -d' ' -f1
>   register: ouputvmid
>
> The value will be in {{ ouputvmid.stdout }}
>
> --
> Kai Stian Olstad
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/to
> pic/ansible-project/TAWwl3sA4tY/unsubscribe.
> To unsubscribe from this group and all its topics, 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/ms
> gid/ansible-project/d5021e3c-b844-b843-2871-05c45d1215ee%40olstad.com.
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [ansible-project] gathering facts on network devices

2017-07-26 Thread Kai Stian Olstad

On 26. juli 2017 17:09, Andrew Meyer wrote:

I seem to be having some issues making this playbook work.  I want to just
do a show run on all my cisco devices, but it keeps throwing errors about
the '- vars:' or something else.  I am on the latest version.
  rpm -qa|grep -i ansible
ansible-inventory-grapher-2.3.2-1.el7.noarch
ansible-2.3.1.0-1.el7.noarch
ansible-review-0.13.0-2.el7.noarch
ansible-openstack-modules-0-20140902git79d751a.el7.noarch
ansible-lint-3.4.12-1.el7.noarch
ansible-doc-2.3.1.0-1.el7.noarch


- vars:
   hosts: cisco-fw

>  cli:

You have them in the wrong order, it should be this way

- hosts: cisco-fw
  vars:
cli:

--
Kai Stian Olstad

--
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/fe46bf8b-7bf4-ee58-af9c-fa7f06b9413e%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Getting a Column value from row

2017-07-26 Thread Kai Stian Olstad

On 26. juli 2017 19:50, Vijay Misra wrote:

Thanks Kai for your quick response !
Here is my output , problem is it does not extract the VMID but outputs the
whole string. I intend to just get the VMID.


I forgot that command doesn't allow pipe, so as James suggested, use the 
shell module. You can also use the raw module.


- name: Get the VM id of the powered ON VM
  shell: vim-cmd vmsvc/getallvms | grep '{{guest_name}}' | cut -d' ' -f1
  register: ouputvmid

or

- name: Get the VM id of the powered ON VM
  raw: vim-cmd vmsvc/getallvms | grep '{{guest_name}}' | cut -d' ' -f1
  register: ouputvmid

The value will be in {{ ouputvmid.stdout }}

--
Kai Stian Olstad

--
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/d5021e3c-b844-b843-2871-05c45d1215ee%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] win_shell/win_command chdir to Directory with Spaces

2017-07-26 Thread Jean-Yves LENHOF


Le 26/07/2017 à 20:10, Nick Couchman a écrit :
> Thank you for the suggestion, Mike.
>
> I've tried it both ways, and neither of them works.  In fact, the
> "YAML Syntax" doesn't seem to actually attempt to change directory -
> if I use that, I get an error along the lines of file not found or
> command not found, indicating that it isn't even going to the
> directory.  If I put it up on the line with win_command, it seems to
> actually try to chdir, but fails due to the space.
>
> I forgot to mention in the original post that I have tried all sorts
> of variations of double and single quotes and combinations thereof,
> and that hasn't made a difference - however it gets passed in to the
> command, it seems like PowerShell ends up interpreting it as
> C:\Program and just chopping it off at the space.
>
> I am able to get a command in a directory to run using PowerShell's
> special escape syntax:
> & 'C:\Program Files\Application\mycmd.exe'
>
> But this doesn't seem to work in the chdir argument.  Unfortunately
> because the application that I'm running relies on the presence of
> certain files in the current working directory, I need to actually
> move to that directory.
>
> Thanks,
> Nick

I always found a bad idea to put space in files or directory names...
but Microsoft did it
There should be a mean to escape it correctly...
But as a workaround, did you try with the 8.3 dos syntax (I hope the
compatibility still exist) ? dir /x will show you what to use... 
(there's a tilda in the name to use often)

Regards,

JYL

>
> On Wednesday, July 26, 2017 at 12:35:59 PM UTC-4, Swedish Mike wrote:
>
> Nick,
>
> I saw it mentioned somewhere that if you use 'YAML syntax'  with
> the :'s instead of Ansibles ='s you should not need escape
> characters for directories with spaces in them. Ie, if you do it
> like this:
>
> - win_command: runsomething.exe
> args:
> chdir: c:\Program Files\Application
>
> The other thing I can think of is adding single quotes ' around
> the path.
>
> Sadly I don't have any Windows boxes around that I can test this
> on right now for you, but it could be worth a try?
>
> Cheers, Mike
>
> On Wed, Jul 26, 2017 at 4:17 PM Nick Couchman
> > wrote:
>
> So, I'm trying to run a command via Ansible, and the command
> exists in a path that's in a directory with spaces, namely
> c:\Program Files.  I need the module to chdir to the directory
> where the command is actually located because there are files
> that it needs to reference inside that directory. 
> Unfortunately it doesn't seem to want to work, no matter what
> I try.  I've tried the following variations on the path to
> make it work:
> C:\Program Files\Application
> C:\\Program Files\\Application
> C:\\Program\ Files\\Application
> C:\\Program^ Files\\Application
> C:/Program Files/Application
> C:/Program\ Files/Application
>
> No matter what I try, here, I get the following message from
> the module:
>
> The directory name is invalid
>
> What's the trick to making chdir work for directories with
> spaces??
>
> Thanks - Nick
> -- 
> 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/8581aa1e-4010-4616-b399-771acf2fa96f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout
> .
>
> -- 
> 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/15ccacde-3e94-4347-a0f7-d5013bbb6d6f%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from th

Re: [ansible-project] win_shell/win_command chdir to Directory with Spaces

2017-07-26 Thread Nick Couchman
Thank you for the suggestion, Mike.

I've tried it both ways, and neither of them works.  In fact, the "YAML 
Syntax" doesn't seem to actually attempt to change directory - if I use 
that, I get an error along the lines of file not found or command not 
found, indicating that it isn't even going to the directory.  If I put it 
up on the line with win_command, it seems to actually try to chdir, but 
fails due to the space.

I forgot to mention in the original post that I have tried all sorts of 
variations of double and single quotes and combinations thereof, and that 
hasn't made a difference - however it gets passed in to the command, it 
seems like PowerShell ends up interpreting it as C:\Program and just 
chopping it off at the space.

I am able to get a command in a directory to run using PowerShell's special 
escape syntax:
& 'C:\Program Files\Application\mycmd.exe'

But this doesn't seem to work in the chdir argument.  Unfortunately because 
the application that I'm running relies on the presence of certain files in 
the current working directory, I need to actually move to that directory.

Thanks,
Nick

On Wednesday, July 26, 2017 at 12:35:59 PM UTC-4, Swedish Mike wrote:
>
> Nick,
>
> I saw it mentioned somewhere that if you use 'YAML syntax'  with the :'s 
> instead of Ansibles ='s you should not need escape characters for 
> directories with spaces in them. Ie, if you do it like this:
>
> - win_command: runsomething.exe
> args:
> chdir: c:\Program Files\Application
>
> The other thing I can think of is adding single quotes ' around the path.
>
> Sadly I don't have any Windows boxes around that I can test this on right 
> now for you, but it could be worth a try?
>
> Cheers, Mike
>
> On Wed, Jul 26, 2017 at 4:17 PM Nick Couchman  > wrote:
>
>> So, I'm trying to run a command via Ansible, and the command exists in a 
>> path that's in a directory with spaces, namely c:\Program Files.  I need 
>> the module to chdir to the directory where the command is actually located 
>> because there are files that it needs to reference inside that directory.  
>> Unfortunately it doesn't seem to want to work, no matter what I try.  I've 
>> tried the following variations on the path to make it work:
>> C:\Program Files\Application
>> C:\\Program Files\\Application
>> C:\\Program\ Files\\Application
>> C:\\Program^ Files\\Application
>> C:/Program Files/Application
>> C:/Program\ Files/Application
>>
>> No matter what I try, here, I get the following message from the module:
>>
>> The directory name is invalid
>>
>> What's the trick to making chdir work for directories with spaces??
>>
>> Thanks - Nick
>>
>> -- 
>> 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/8581aa1e-4010-4616-b399-771acf2fa96f%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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/15ccacde-3e94-4347-a0f7-d5013bbb6d6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Getting a Column value from row

2017-07-26 Thread Jean-Yves LENHOF


Le 26/07/2017 à 19:50, Vijay Misra a écrit :
> Thanks Kai for your quick response !
> Here is my output , problem is it does not extract the VMID but
> outputs the whole string. I intend to just get the VMID.
>
> TASK [ESX_VM_SnapRestore : debug]
> 
> ok: [10.114.22.61] => {
> "changed": false,
> "ouputvmid": {
> "changed": true,
> "cmd": [
> "vim-cmd",
> "vmsvc/getallvms",
> "|",
> "grep",
> "myvgpu_clone2",
> "|",
> "'cut -d ' ' -f 1'"
> ],
> "delta": "0:00:00.455803",
> "end": "2017-07-26 07:10:17.235366",
> "rc": 0,
> "start": "2017-07-26 07:10:16.779563",
> "stderr": "",
> "stderr_lines": [],
> "stdout": "Vmid   Name   
> File   Guest OS   Version  
> Annotation\n51 myvgpu_clone2   [EVC_Store1]
> myvgpu_clone2/myvgpu_clone2.vmx   windows8_64Guest  
> vmx-11  ",
> "stdout_lines": [
>"Vmid   Name   
> File   Guest OS   Version   Annotation",
> *"51* myvgpu_clone2   [EVC_Store1]
> myvgpu_clone2/myvgpu_clone2.vmx   windows8_64Guest   vmx-11  "
> ]
> }
> }
>
> Though when i run it on ESX command line . it outputs the VMID as below.
>
>
> vim-cmd vmsvc/getallvms | grep 'myvgpu_clone2'| cut -d ' ' -f 1
>
>
>  51
>

use :
ouputvmid.stdout_lines[2]
and filter it with the good regexp with regexp_replace

Regards,

JYL



-- 
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/9031bc1c-574b-3f3a-3fe2-c2aeeb866a07%40lenhof.eu.org.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Getting a Column value from row

2017-07-26 Thread James Tanner
Try using the shell module instead of command.

On Wed, Jul 26, 2017 at 1:50 PM, Vijay Misra  wrote:

> Thanks Kai for your quick response !
> Here is my output , problem is it does not extract the VMID but outputs
> the whole string. I intend to just get the VMID.
>
> TASK [ESX_VM_SnapRestore : debug] **
> 
> **
> ok: [10.114.22.61] => {
> "changed": false,
> "ouputvmid": {
> "changed": true,
> "cmd": [
> "vim-cmd",
> "vmsvc/getallvms",
> "|",
> "grep",
> "myvgpu_clone2",
> "|",
> "'cut -d ' ' -f 1'"
> ],
> "delta": "0:00:00.455803",
> "end": "2017-07-26 07:10:17.235366",
> "rc": 0,
> "start": "2017-07-26 07:10:16.779563",
> "stderr": "",
> "stderr_lines": [],
> "stdout": "Vmid   Name
> File   Guest OS   Version   Annotation\n51
> myvgpu_clone2   [EVC_Store1] myvgpu_clone2/myvgpu_clone2.vmx
> windows8_64Guest   vmx-11  ",
> "stdout_lines": [
> "Vmid   Name
> File   Guest OS   Version   Annotation",
> *"51* myvgpu_clone2   [EVC_Store1]
> myvgpu_clone2/myvgpu_clone2.vmx   windows8_64Guest   vmx-11  "
> ]
> }
> }
>
> Though when i run it on ESX command line . it outputs the VMID as below.
>
>
> vim-cmd vmsvc/getallvms | grep 'myvgpu_clone2'| cut -d ' ' -f 1 51
>
>
>
> On Wed, Jul 26, 2017 at 7:13 AM, Kai Stian Olstad <
> ansible-project+l...@olstad.com> wrote:
>
>> On 26. juli 2017 09:29, Vijay Misra wrote:
>>
>>> I need to get the VMID field from the column data as below.
>>>
>>> [[root@prmh-mag-31:~] vim-cmd vmsvc/getallvms
>>> Vmid   NameFile
>>> Guest OS   Version   Annotation
>>> 51 myvgpu_clone2   [EVC_Store1] myvgpu_clone2/myvgpu_clone2.vmx
>>> windows8_64Guest   vmx-11
>>>
>>> so as above is the command result , i  need to get the VMID corresponding
>>> to vm name myvgpu_clone2. For that i have used ansible command module and
>>> grepping the first output of vm list for vmname so i get the one row .
>>> now
>>> i have to get the VMID field from the single row.
>>>
>>> I have used following code but it does not give the desired output. any
>>> help is aprreciated.
>>>
>>
>> What output do you get and what's wrong with it?
>>
>>
>>   name: Get the VM id of the powered ON VM
>>>  command: vim-cmd vmsvc/getallvms | grep '{{guest_name}}' |
>>> "'cut -d
>>> ' ' -f 1'"
>>>  register: ouputvmid
>>>  ignore_errors: true
>>>
>>
>> Not all esx have python so you might need to use the raw module.
>>
>> You need to remove the single and double quotes around cut like so.
>>
>>   - name: Get the VM id of the powered ON VM
>> command: vim-cmd vmsvc/getallvms | grep '{{guest_name}}' | cut -d' '
>> -f1
>> register: ouputvmid
>>
>>
>> --
>> Kai Stian Olstad
>>
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Ansible Project" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/ansible-project/TAWwl3sA4tY/unsubscribe.
>> To unsubscribe from this group and all its topics, 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/ms
>> gid/ansible-project/26f1c6cf-a690-d449-d86e-1db528118b09%40olstad.com.
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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/CAKcuOAzY67jTMG9Rh%3Dkr3sZYAfrkFA%
> 2BK5TB7x9evpG3xZW9Swg%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAMSYDtx9DvtVtxyfzCH1ddN1OrCZ07nYN79C8nxzabxRCZedGQ%40mail.gmail.com.
For more options, visit https://groups.g

Re: [ansible-project] Getting a Column value from row

2017-07-26 Thread Vijay Misra
Thanks Kai for your quick response !
Here is my output , problem is it does not extract the VMID but outputs the
whole string. I intend to just get the VMID.

TASK [ESX_VM_SnapRestore : debug] **

**
ok: [10.114.22.61] => {
"changed": false,
"ouputvmid": {
"changed": true,
"cmd": [
"vim-cmd",
"vmsvc/getallvms",
"|",
"grep",
"myvgpu_clone2",
"|",
"'cut -d ' ' -f 1'"
],
"delta": "0:00:00.455803",
"end": "2017-07-26 07:10:17.235366",
"rc": 0,
"start": "2017-07-26 07:10:16.779563",
"stderr": "",
"stderr_lines": [],
"stdout": "Vmid   Name
File   Guest OS   Version   Annotation\n51
myvgpu_clone2   [EVC_Store1] myvgpu_clone2/myvgpu_clone2.vmx
windows8_64Guest   vmx-11  ",
"stdout_lines": [
"Vmid   Name
File   Guest OS   Version   Annotation",
*"51* myvgpu_clone2   [EVC_Store1]
myvgpu_clone2/myvgpu_clone2.vmx   windows8_64Guest   vmx-11  "
]
}
}

Though when i run it on ESX command line . it outputs the VMID as below.


vim-cmd vmsvc/getallvms | grep 'myvgpu_clone2'| cut -d ' ' -f 1 51



On Wed, Jul 26, 2017 at 7:13 AM, Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On 26. juli 2017 09:29, Vijay Misra wrote:
>
>> I need to get the VMID field from the column data as below.
>>
>> [[root@prmh-mag-31:~] vim-cmd vmsvc/getallvms
>> Vmid   NameFile
>> Guest OS   Version   Annotation
>> 51 myvgpu_clone2   [EVC_Store1] myvgpu_clone2/myvgpu_clone2.vmx
>> windows8_64Guest   vmx-11
>>
>> so as above is the command result , i  need to get the VMID corresponding
>> to vm name myvgpu_clone2. For that i have used ansible command module and
>> grepping the first output of vm list for vmname so i get the one row . now
>> i have to get the VMID field from the single row.
>>
>> I have used following code but it does not give the desired output. any
>> help is aprreciated.
>>
>
> What output do you get and what's wrong with it?
>
>
>   name: Get the VM id of the powered ON VM
>>  command: vim-cmd vmsvc/getallvms | grep '{{guest_name}}' | "'cut
>> -d
>> ' ' -f 1'"
>>  register: ouputvmid
>>  ignore_errors: true
>>
>
> Not all esx have python so you might need to use the raw module.
>
> You need to remove the single and double quotes around cut like so.
>
>   - name: Get the VM id of the powered ON VM
> command: vim-cmd vmsvc/getallvms | grep '{{guest_name}}' | cut -d' '
> -f1
> register: ouputvmid
>
>
> --
> Kai Stian Olstad
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/to
> pic/ansible-project/TAWwl3sA4tY/unsubscribe.
> To unsubscribe from this group and all its topics, 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/ms
> gid/ansible-project/26f1c6cf-a690-d449-d86e-1db528118b09%40olstad.com.
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: [ansible-project] win_shell/win_command chdir to Directory with Spaces

2017-07-26 Thread Mike Eriksson
Nick,

I saw it mentioned somewhere that if you use 'YAML syntax'  with the :'s
instead of Ansibles ='s you should not need escape characters for
directories with spaces in them. Ie, if you do it like this:

- win_command: runsomething.exe
args:
chdir: c:\Program Files\Application

The other thing I can think of is adding single quotes ' around the path.

Sadly I don't have any Windows boxes around that I can test this on right
now for you, but it could be worth a try?

Cheers, Mike

On Wed, Jul 26, 2017 at 4:17 PM Nick Couchman 
wrote:

> So, I'm trying to run a command via Ansible, and the command exists in a
> path that's in a directory with spaces, namely c:\Program Files.  I need
> the module to chdir to the directory where the command is actually located
> because there are files that it needs to reference inside that directory.
> Unfortunately it doesn't seem to want to work, no matter what I try.  I've
> tried the following variations on the path to make it work:
> C:\Program Files\Application
> C:\\Program Files\\Application
> C:\\Program\ Files\\Application
> C:\\Program^ Files\\Application
> C:/Program Files/Application
> C:/Program\ Files/Application
>
> No matter what I try, here, I get the following message from the module:
>
> The directory name is invalid
>
> What's the trick to making chdir work for directories with spaces??
>
> Thanks - Nick
>
> --
> 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/8581aa1e-4010-4616-b399-771acf2fa96f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


[ansible-project] Small Example for Reading from CSV-File for the creation of new user

2017-07-26 Thread 'Dan Steffen' via Ansible Project
Hello,

maybe I am just blind but I spend today 2 hours to found out how to read 
from a CSV to create User at the moment I have something like

- hosts: all
  user:
name="{{ lookup('csvfile', 'item file=user.csv delimiter=, col=0') }}"



and a CSV-File that looks like

jdoe
jkirk
bwillis



I already know that I have to declare the "item" Variable so I can iterate 
through the user.csv but I don't can figured out how, maybe someone here 
can give me a little how to define the item-Variable I would very thanksful
best regards
Dan

-- 
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/e7608c21-7066-4fc8-a55f-9bd94fd0a7aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] docker_container network issue

2017-07-26 Thread sn . lazamanthony
Hi, I've been using the docker_container module. So far it's working when 
creating the image and other options, but when the "networks" option is 
used then the issue arise.

Here's the details:

ansible version: ansible 2.2.1.0 (master d5f68d2824) last updated 
2017/07/26 15:11:46 (GMT +800)
docker-py version: docker-py (1.9.0)
docker version:   1.9.0
docker API version:  1.21

Error encountered: 

fatal: [10.0.1.110]: FAILED! => {"changed": false, "failed": true, 
"module_stderr": "Warning: Permanently added 'host here' (ECDSA) to the 
list of known hosts.\r\nWarning: Permanently added '10.0.1.110' (ECDSA) to 
the list of known hosts.\r\nTraceback (most recent call last):\n  File 
\"/tmp/ansible_cdG2O6/ansible_module_docker_container.py\", line 2007, in 
\nmain()\n  File 
\"/tmp/ansible_cdG2O6/ansible_module_docker_container.py\", line 2000, in 
main\ncm = ContainerManager(client)\n  File 
\"/tmp/ansible_cdG2O6/ansible_module_docker_container.py\", line 1652, in 
__init__\nself.present(state)\n  File 
\"/tmp/ansible_cdG2O6/ansible_module_docker_container.py\", line 1696, in 
present\ncontainer = self.update_networks(container)\n  File 
\"/tmp/ansible_cdG2O6/ansible_module_docker_container.py\", line 1761, in 
update_networks\nhas_network_differences, network_differences = 
container.has_network_differences()\n  File 
\"/tmp/ansible_cdG2O6/ansible_module_docker_container.py\", line 1374, in 
has_network_differences\nif connected_networks.get(network['name'], 
None) is None:\nAttributeError: 'NoneType' object has no attribute 
'get'\nKilled by signal 1.\r\n", "module_stdout": "", "msg": "MODULE 
FAILURE"}




Playbook:
- name: Pull and spawn docker image {{ container_name }} {{ container_tag }}
  docker_container:
name: "{{ container_name }}"
image: "{{ docker_image }}"
state: present
ports: "{{ container_ports|default(omit) }}"
pull: true
networks:
  - name: bridge
ipv4_address: "{{ docker_image }}"



There error doesn't appear when I don't include any network option in 
docker_container module. Any help why this is happening?

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/62ba0d71-0289-45a5-899b-e0b21483f6f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Does command module honor wildcards?

2017-07-26 Thread Josef Fortier

>
>
> Command module does not support globs so you would need to use shell 
> with globs. 
>

Ahh... Thanks.

FWIW, Looking at the command module docs I do see this telling note:
>> "It will not be processed through the shell"
But I'd only get the lack of glob support from that sentence implicitly; 
the explicit references are to job control and redirection modifiers.

To do is the more Ansible way, you need two task. 
> First one with the find module, that support globs or regexp
>

Thanks :-) I'm sure I'll end up using that regex support down the road.

-- 
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/3c0754fb-1734-4b96-ad85-b2dee33bc371%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible 2.3.2 RC4 is available for testing

2017-07-26 Thread James Cammarata
Hi all, we're happy to announce that Ansible 2.3.2 RC4 is available for
testing.

A list of fixes can be found in the CHANGELOG here:

https://github.com/ansible/ansible/blob/v2.3.2.0-0.4.rc4/CHANGELOG.md#bugfixes


How do you get it?
--

The tar.gz of the release can be found here:

http://releases.ansible.com/ansible/ansible-2.3.2.0-0.4.rc4.tar.gz
SHA256: 1cd21a8cefe8d98c17e794eeae8c34a581d6562eb4416665b418d424e32f6f7a

You can also test against the git repository as follows:

$ git clone https://github.com/ansible/ansible.git
$ cd ansible
$ git checkout 
$ git submodule update --init

You can then source our testing script:

$ . hacking/env-setup

or you can build your own .tar.gz (output will be in the dist/ directory):

$ make sdist

If you discover any errors, or if you see any regressions from playbooks
which work on 1.9.x and prior, please open a Github issue and be sure to
mention you're testing against this release candidate.

Thanks!

James Cammarata

Ansible Lead/Sr. Principal Software Engineer
Ansible by Red Hat
twitter: @thejimic, github: jimi-c

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


[ansible-project] win_shell/win_command chdir to Directory with Spaces

2017-07-26 Thread Nick Couchman
So, I'm trying to run a command via Ansible, and the command exists in a 
path that's in a directory with spaces, namely c:\Program Files.  I need 
the module to chdir to the directory where the command is actually located 
because there are files that it needs to reference inside that directory. 
 Unfortunately it doesn't seem to want to work, no matter what I try.  I've 
tried the following variations on the path to make it work:
C:\Program Files\Application
C:\\Program Files\\Application
C:\\Program\ Files\\Application
C:\\Program^ Files\\Application
C:/Program Files/Application
C:/Program\ Files/Application

No matter what I try, here, I get the following message from the module:

The directory name is invalid

What's the trick to making chdir work for directories with spaces??

Thanks - Nick

-- 
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/8581aa1e-4010-4616-b399-771acf2fa96f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] gathering facts on network devices

2017-07-26 Thread Andrew Meyer
I seem to be having some issues making this playbook work.  I want to just 
do a show run on all my cisco devices, but it keeps throwing errors about 
the '- vars:' or something else.  I am on the latest version.
 rpm -qa|grep -i ansible
ansible-inventory-grapher-2.3.2-1.el7.noarch
ansible-2.3.1.0-1.el7.noarch
ansible-review-0.13.0-2.el7.noarch
ansible-openstack-modules-0-20140902git79d751a.el7.noarch
ansible-lint-3.4.12-1.el7.noarch
ansible-doc-2.3.1.0-1.el7.noarch


- vars:
  hosts: cisco-fw
cli:
  hosts: "{{ cisco-fw }}"
  username: user
  password: password
  authorize: yes
  auth_pass: password
  transport: cli

  tasks:
  - asa_command:
  commands:
- show version
  provider: "{{ cli }}"

  - asa_command:
  commands:
- show run
- show memory
  provider: "{{ cli }}"

  - asa_command:
  commands:
- show version
  provider: "{{ cli }}"
  context: system

Here is my output:

sudo ansible-playbook asa-showrun.yml --check
ERROR! Syntax Error while loading YAML.


The error appears to have been in 
'/home/andrew.meyer/playbooks/asa-showrun.yml': line 3, column 8, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  hosts: cisco-fw
cli:
   ^ here

-- 
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/cbf43107-7189-4745-b127-0a08bcb7f634%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Building Module - Unable to set correct type for DEFAULT_LOCAL_TMP

2017-07-26 Thread Kai Stian Olstad

On 26. juli 2017 14:28, Luvpreet Singh wrote:

I have just started to learn on how to build modules in Ansible.


I can't help with you problem, but wanted mention that Ansible has a 
list for development, you might have better luck there.


https://docs.ansible.com/ansible/latest/community.html#mailing-list-information



--
Kai Stian Olstad

--
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/d20af4e1-7224-79db-dfba-6757528278e6%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Getting a Column value from row

2017-07-26 Thread Kai Stian Olstad

On 26. juli 2017 09:29, Vijay Misra wrote:

I need to get the VMID field from the column data as below.

[[root@prmh-mag-31:~] vim-cmd vmsvc/getallvms
Vmid   NameFile
Guest OS   Version   Annotation
51 myvgpu_clone2   [EVC_Store1] myvgpu_clone2/myvgpu_clone2.vmx
windows8_64Guest   vmx-11

so as above is the command result , i  need to get the VMID corresponding
to vm name myvgpu_clone2. For that i have used ansible command module and
grepping the first output of vm list for vmname so i get the one row . now
i have to get the VMID field from the single row.

I have used following code but it does not give the desired output. any
help is aprreciated.


What output do you get and what's wrong with it?



  name: Get the VM id of the powered ON VM
 command: vim-cmd vmsvc/getallvms | grep '{{guest_name}}' | "'cut -d
' ' -f 1'"
 register: ouputvmid
 ignore_errors: true


Not all esx have python so you might need to use the raw module.

You need to remove the single and double quotes around cut like so.

  - name: Get the VM id of the powered ON VM
command: vim-cmd vmsvc/getallvms | grep '{{guest_name}}' | cut -d' 
' -f1

register: ouputvmid


--
Kai Stian Olstad

--
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/26f1c6cf-a690-d449-d86e-1db528118b09%40olstad.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] 2.4 support for multiple vault passwords, looking for feedback

2017-07-26 Thread Adrian Likins
I've been working on some vault related 2.4 roadmap[1] features,
namely "Support for multiple vault passwords. ".

The current pr is at https://github.com/ansible/ansible/pull/22756

The roadmap feature is based on RFE
https://github.com/ansible/ansible/issues/13243


Looking for feedback from vault users on the proposed interface and
approach.


For convenience, I'll include the summary of the proposed changes from
https://github.com/ansible/ansible/pull/22756#issue-215127152 inline
here, but may be easier to read on the issue:




The main user facing changes are:

- Cli now supports a new '--vault-id' option that can specify a
password file or 'prompt'

 "ansible-playbook --ask-vault-pass --vault-id ~/dev_password
--vault-id prompt some_playbook.yml"

  - Will prompt for a vault password (it will ask for the
'default' password in this example)
  - Will read a password from ~/dev_password

  For example above, the ~/dev_password file would be tried first,
then the password from the prompt


- Cli now supports providing --vault-password-file multiple times

   "ansible-playbook --vault-password-file ~/dev_password
--vault-password-file ~/prod_password  some_playbook.yml"

  The default behavior is to try all of the specified vault
secrets/passwords in the order they were specified, until one work
  the new '--vault-id' option can be mixed in with the existing
--vault-password-file and --ask-vault-pass as well

- internally vault can add the vault-id label to the vault format

- vault format is rev'ed to 1.2
  (but anything that can read 1.1 format can read 1.2 as well)

- When decrypting a 1.2 format with a 'vault-id', the vault secrets
that match that vault id will be tried first

- The --vault-id option also allows specifying a vault id label and
the secret type

"ansible-playbook --vault-id prod_keychain@prod_password_file
--vault-id stage_keychain@prompt some_playbook.yml"

   tTat will read ./prod_password_file and then prompt the user for
the password for the 'stage_keychain' vault id

- A playbook can have have vaulted files that uses different passwords
in the same 'ansible-playbook' run

- A playbook can have embedded vaulted variables with different
passwords in the same playbook (even in same file)

So a ansible project like:

   secrets/dev_password
   secrets/qa_password
   playbooks/
   playbooks/inventory   # encrypted with dev password
   playbooks/site.yml
   playbooks/vars/main.yml   # with multiple embedded
vars, each with a different password and/or vault id

dev_password would be loaded from file, and there will be an
interactive prompt for 'prod' vault_id/password



* Not quite done but close

  config option and/or cli option to enforce matching vault_id and
vault_secret

  If a vault is of label 'dev_keychain', then decrypting will
'require'[1] a vault id for 'dev_keychain' is provided

# with "enforcing" enabled in config
ansible-playbook --vault-id dev_password
playbook_that_has_vaults_for_dev_keychain.yml

  will fail indicating that '--vault-id dev_keychain@dev_password' is needed

  This will help with the case where multiple vault items with
different vault ids also happen to all use the same password.

[1] require and enforcing in scare quotes, because that would be app
level logic and not a cryptographic requirement. ie, I could edit the
vault cipher text to change the vault id to 'dev' and above command
would succeed. (The vault-id is primarily a nickname used in the UX,
it is not signed or encrypted since that would require changing the
vault format in a non backwards compatible way).


* Not for 2.4

automatically choosing what vault passwords to interactively prompt
for based on which playbook content is loaded.
(that would be nice UX, but ansible doesn't know what it needs to
decrypt until way too late (in the worker processes...). We can fix
that, but it may need some significant changes to other parts of
ansible.


* Partial for 2.4

the secret/password callbacks mentioned in the roadmaps.
Same issue as above. It could work in my branch for non-interactive
callbacks, but the normal interactive console prompts do not.




[1] https://github.com/ansible/ansible/blob/devel/docs/
docsite/rst/roadmap/ROADMAP_2_4.rst#vault

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


Re: [ansible-project] parsing output from json

2017-07-26 Thread Kai Stian Olstad

On 26.07.2017 14:03, akku wrote:
yes... with this it prints the path and size along with the whole 
output.

 but  i need only the parsed output.


You don't say what you are going to use this for.
If you would like it in a file, use the template module.

If you would like to have it displayed nice on the screen you are 
probably using the wrong tool.

Ansible is not a reporting tool but a configuration management tool.
But you could write your one callback plugin to make the output the way 
you want it to be.


--
Kai Stian Olstad

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


[ansible-project] Building Module - Unable to set correct type for DEFAULT_LOCAL_TMP

2017-07-26 Thread Luvpreet Singh
I have just started to learn on how to build modules in Ansible.

I have followed this page,  
http://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html

I created the python file, cloned the ansible repo told there, and ran the 
command, 

ansible/hacking/test-module -m ./timetest.py

But I am getting something like this, 

Unable to set correct type for DEFAULT_LOCAL_TMP, skipping* including generated 
source, if any, saving to: /home/luvpreet/.ansible_module_generated
***
RAW OUTPUT
{"time": "2017-07-26 17:55:17.854018"}


***
PARSED OUTPUT
{
"time": "2017-07-26 17:55:17.854018"
}
Traceback (most recent call last):
  File "ansible/hacking/test-module", line 271, in 
shutil.rmtree(C.DEFAULT_LOCAL_TMP, True)
AttributeError: 'module' object has no attribute 'DEFAULT_LOCAL_TMP'


What is the issue here ?

-- 
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/fd4be6ef-d0b5-45ff-93f9-c1a07912dae5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] parsing output from json

2017-07-26 Thread akku

yes... with this it prints the path and size along with the whole output. 
 but  i need only the parsed output.

On Wednesday, July 26, 2017 at 11:20:14 AM UTC+5:30, Kai Stian Olstad wrote:
>
> On 25. juli 2017 23:03, akku wrote: 
> > Am using find modules to get largest files and its size the file, I am 
> > getting a big jason format output, How can i parse one particular string 
> > from the output. 
> > I need to fetch only the "path" and "size" values from here. Can anyone 
> > help me on this? 
> > -- 
> > 
> > - hosts: localhost 
> > connection: local 
> > become: true 
> > vars: 
> > var1: '{{ choice }}'var2: '{{ fspath }}'gather_facts: true 
> > tasks: 
> >- 
> > 
> >find: paths="/var/log" age="0d" size="1m" patterns="*.old,*.log" 
> >recurse=yes 
> >register: logfile 
> >when: var1 == "getLogs" 
>
> How, depends on what you are going to do with path and size, so this is 
> one of several ways. 
>
>- debug: msg="{{ item.path }} - {{ item.size }}" 
>  with_items: "{{ logfile.files }}" 
>
>
> -- 
> Kai Stian Olstad 
>

-- 
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/110f892f-a8b4-46c2-99a9-22a822d65511%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: How to read the JSON output of a module from another module I am creating

2017-07-26 Thread russell choudhury
Ahh I got it, seems like ansible auto-magically converts the json to dict 
so I just changed the type from 'string' to 'dict'

On Wednesday, July 26, 2017 at 11:23:24 AM UTC+1, russell choudhury wrote:
>
> I want to be able to read the output from a specific task in the module I 
> am creating.
> To do this I am registering the output into a variable in my playbook and 
> then sending this as a argument in my module. 
> The format of the variable is json, I am reading this in my python script 
> as a string and trying to convert to json
> this is where I am having problems. The json read as a string is not in 
> the correct format (its in one line and has single quotes)
>
> If there is a better way of reading the output from one module in another 
> module I would like to hear about it.
> Thanks for your help
> =
>
> Here is the playbook (playbook.yml):
>
> ---
> - name: Napalm get facts
>   hosts: "ios-devices"
>   gather_facts: false
>   connection: local
>
>
>   tasks: #Begin Tasks
> - name: get facts from device#Task Name
>   napalm_get_facts:  #Call the napalm module, in 
> this case napal_get_facts
> hostname: "{{ ansible_host }}" #This is a parameter and is derived 
> from your ansible inventory file
> username: '{{ ansible_user }}' #The username 
> to ssh with
> dev_os: 'ios'#The hardware operating system
> password: '{{ ansible_password }}' #The line level 
> password
> filter: 'facts'  #The list of items you want 
> to retrieve. The filter keyword is _inclusive_ of what you want
>   register: output   #Ansible function for 
> collecting output
>
> - name: Test that my module works
>   facts_output: 
> content: "{{ output }}"
> dest: ./output/{{ inventory_hostname }}.csv
>   register: result
>
> - debug: var=result  
>
> ==
> Python module (facts_output.py)
>
> #!/usr/bin/python
> import csv
> import json
> from pprint import pprint
> from ansible.module_utils.basic import *
>
> def main():
>   fields = {
> "content": {"required": True, "type": "str" },
> "dest": {"required": True, "type": "str" },
>   }
>   module = AnsibleModule(argument_spec=fields)
>
>   #import epdb; epdb.serve()
>   
>   d = json.load(module.params['content'])
>   my_dict = d['msg']['ansible_facts']['facts']
>
>   with open(module.params['dest'], 'wb') as f:  # Just use 'w' mode in 3.x
> w = csv.DictWriter(f, my_dict.keys())
> w.writeheader()
> w.writerow(my_dict)
>
>   
>   module.exit_json(changed=False, meta=module.params)
>
>
> if __name__ == '__main__':  
>   main()
>
>

-- 
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/f300715a-40e7-4745-a791-5e3b5064ade5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] how to debug ansible seg vault ?

2017-07-26 Thread Mike C
im getting a seg fault when im running my ansible. Is there a way to turn 
on more debugging or anything that can help me find out the source ?

My `/var/log/syslog` has entries like this

```
Jul 26 10:47:26 ubuntu-xenial kernel: [  497.822661] 
ansible-playboo[13890]: segfault at a9 ip 004a7ee4 sp 
7ffdabc1b128 error 4 in python2.7[40+2ea000]
```

I've tried `-` but no luck there.

Cheers

-- 
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/8e70a592-86bd-4cee-8f9f-4736fad8ed95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] How to read the JSON output of a module from another module I am creating

2017-07-26 Thread russell choudhury
I want to be able to read the output from a specific task in the module I 
am creating.
To do this I am registering the output into a variable in my playbook and 
then sending this as a argument in my module. 
The format of the variable is json, I am reading this in my python script 
as a string and trying to convert to json
this is where I am having problems. The json read as a string is not in the 
correct format (its in one line and has single quotes)

If there is a better way of reading the output from one module in another 
module I would like to hear about it.
Thanks for your help
=

Here is the playbook (playbook.yml):

---
- name: Napalm get facts
  hosts: "ios-devices"
  gather_facts: false
  connection: local


  tasks: #Begin Tasks
- name: get facts from device#Task Name
  napalm_get_facts:  #Call the napalm module, in 
this case napal_get_facts
hostname: "{{ ansible_host }}" #This is a parameter and is derived 
from your ansible inventory file
username: '{{ ansible_user }}' #The username to 
ssh with
dev_os: 'ios'#The hardware operating system
password: '{{ ansible_password }}' #The line level 
password
filter: 'facts'  #The list of items you want to 
retrieve. The filter keyword is _inclusive_ of what you want
  register: output   #Ansible function for 
collecting output

- name: Test that my module works
  facts_output: 
content: "{{ output }}"
dest: ./output/{{ inventory_hostname }}.csv
  register: result

- debug: var=result  

==
Python module (facts_output.py)

#!/usr/bin/python
import csv
import json
from pprint import pprint
from ansible.module_utils.basic import *

def main():
  fields = {
"content": {"required": True, "type": "str" },
"dest": {"required": True, "type": "str" },
  }
  module = AnsibleModule(argument_spec=fields)

  #import epdb; epdb.serve()
  
  d = json.load(module.params['content'])
  my_dict = d['msg']['ansible_facts']['facts']

  with open(module.params['dest'], 'wb') as f:  # Just use 'w' mode in 3.x
w = csv.DictWriter(f, my_dict.keys())
w.writeheader()
w.writerow(my_dict)

  
  module.exit_json(changed=False, meta=module.params)


if __name__ == '__main__':  
  main()

-- 
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/dfbd9be4-2295-4c24-9b98-8fa76a162404%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Add role dependency to another role without it being executed automatically

2017-07-26 Thread Adam Addamsky
On Friday, July 7, 2017 at 9:22:18 PM UTC+1, Dick Davies wrote:

> Why not just stick the slack tasks in the relevant roles? 
>
In this speci 
That would result in a lot of duplicated code and potential problems with 
maintainability. Also, that practice leads to "inventing the wheel all over 
again" rather than reusing existing solutions.

In this specific example 

-- 
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/ebfb92be-fca5-4383-ba96-e7e598bc2c64%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Getting a Column value from row

2017-07-26 Thread Vijay Misra
I need to get the VMID field from the column data as below.

[[root@prmh-mag-31:~] vim-cmd vmsvc/getallvms
Vmid   NameFile   
Guest OS   Version   Annotation
51 myvgpu_clone2   [EVC_Store1] myvgpu_clone2/myvgpu_clone2.vmx   
windows8_64Guest   vmx-11

so as above is the command result , i  need to get the VMID corresponding 
to vm name myvgpu_clone2. For that i have used ansible command module and 
grepping the first output of vm list for vmname so i get the one row . now 
i have to get the VMID field from the single row.

I have used following code but it does not give the desired output. any 
help is aprreciated.

Thanks,
VM



 name: Get the VM id of the powered ON VM
command: vim-cmd vmsvc/getallvms | grep '{{guest_name}}' | "'cut -d 
' ' -f 1'"
register: ouputvmid
ignore_errors: true

  - debug:
  var: ouputvmid



  

-- 
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/b9071026-32f0-4ba1-baf3-61ad3d1be963%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Fetch Time Out with Windows Server 2008 SP2 and R2 - Works for Server 2012

2017-07-26 Thread Richard Rogers
Further to your reply,
The servers do have that KB installed - one of the first things I checked.
The Ansible server has only recently been built, so would expect it to be 
up to date.
Testing has also only been with one server at a time.
Yes, also tried flat='no' - obviously then saved file in subfolder, but 
still failed at exactly same point (41,472KB - is this size significant as 
I get it every time on all Server 2008 SP2 servers?)

Richie

-- 
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/8926b110-adc2-410c-b18b-d51561d45b0d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Fetch Time Out with Windows Server 2008 SP2 and R2 - Works for Server 2012

2017-07-26 Thread Richard Rogers
Hi,
To further clarify on this, I have made some changes, including the 
following:
ansible_winrm_operation_timeout_sec=800
ansible_winrm_read_timeout_sec=900
Although not sure the above fixed the issue.
I can now connect to Server 2008 R2.
However, I still can't connect to Server 2008 SP2 - it stops on any file 
over about 45Mb at precisely the same point on multiple Server 2008 SP2 
servers. I can only conclude that you can't use Fetch with them to upload 
files larger than this.

Richie

-- 
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/c32670a0-ddc1-4232-8833-099c3d466ab4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.