[ansible-project] Conditional variables

2016-06-14 Thread Pavel Stratil
Hey all, i'm trying to write a task to manage ssh keys. depending on that the ansible_user, i want teo work either in /root/.ssh or /home/$user/.ssh. So I naively googled how to do that and only ended confused with - set_fact: userdir="/home/{{ ansible_user }}" when: ssh_keygen_user !=

Re: [ansible-project] Python script with Json output as inventory

2016-06-14 Thread Idan null
So if my python script will run a python script that return JSON will it work ? I mean if i do something like that: $ python Ansible.py -i inv.py And the inv.py will return JSON Or it have to be $ ansible -m ping -i inv.py All this hassle is because I got different servers with different ports

Re: [ansible-project] Python script with Json output as inventory

2016-06-14 Thread Matt Martz
host_list cannot accept a JSON string. It expects either a CSV string of hosts, the path to an INI formatted file, or a path to a script that can be executed to return the JSON you are trying to pass directly to host_list. On Tuesday, June 14, 2016, Idan null wrote: > Hello

[ansible-project] Python script with Json output as inventory

2016-06-14 Thread Idan null
Hello to everyone :) I'm quite new to Ansible. I have used the Python API for ansible to connect to a few servers I have, I want to get the inventory list for the python script from MySQL server, so as far as I understood the list should be in Json format (this is because each host have

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

2016-06-14 Thread Rajas Pimpalwadkar
I want to add locking around some part of a playbook. For this I need to get the process id of ansible-playbook that has started the task that I am currently running. How do I get process id of ansible-playbook that the current task is part of? I cannot use grep reliable because there could be

Re: [ansible-project] need help in checking if a variable string is in an item string

2016-06-14 Thread Jerome Yanga
Kai, Thanks. You have been very helpful. Regards, j On Tuesday, June 14, 2016 at 1:10:05 PM UTC-7, Kai Stian Olstad wrote: > > On 14. juni 2016 19:53, Jerome Yanga wrote: > > Thanks, Kai. > > > > You hit the nail on the head. If there is a doc on how to do this > string > > manipulation,

[ansible-project] Re: win_package uninstall example?

2016-06-14 Thread Matt Davis
Ansible's a pretty thin wrapper around the platform capabilities- installing/uninstalling software on Windows is tricky, as every installer is a special snowflake, and many assume that there's a user sitting there to answer dialogs. That said, I know Sliverlight fully supports unattended

[ansible-project] Re: Serial: usage across multiple plays

2016-06-14 Thread Jason Gilfoil
Found a workable answer in another thread here indirectly. I can use the when clause on roles to gate the execution of a role. It will look like this: - hosts: nonprod-app-servers > serial: "30%" > pre_tasks: > - name: disable node in the F5 Pool > roles: > - {role: ps-common, when:

Re: [ansible-project] need help in checking if a variable string is in an item string

2016-06-14 Thread Kai Stian Olstad
On 14. juni 2016 19:53, Jerome Yanga wrote: Thanks, Kai. You hit the nail on the head. If there is a doc on how to do this string manipulation, please share with me the URL. I have just picked it up, but I guess it's a Python string method

[ansible-project] Re: Finding a string within an stdout_lines array

2016-06-14 Thread jamesvader13
The error message is strange and I can not reproduce it in Ansible 2. But your condition still will not work, a list does not have a find method. In Ansible you can search a list with in: roles: - all_servers - {role: production_server, when: '"P" in prod_fact'} On Tuesday, June 14,

[ansible-project] Finding a string within an stdout_lines array

2016-06-14 Thread jamesvader13
I am trying to find whether a certain letter exists in an stdout_lines array. I want the role to run if there is a 'P' found in the stdout_output. The stdout_lines array looks like this "stdout": "P\r\nA\r\nS\r\nI\r\n", *"stdout_lines": ["P", "A", "S", "I"]* myrole.yml --- - hosts: windows

[ansible-project] Error while using ansible with aws

2016-06-14 Thread challa . tek
i am using ansible 2.1.0.0, when i execute a playbook against ec2 console i am finding this error Error: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"assign_public_ip": false, "aws_access_key": null, "aws_region": "us-east-1", "aws_secret_key": null, "count":

[ansible-project] template module setting variables to unicode

2016-06-14 Thread Henry Mendez
Hi, I've recently updated from 1.9.1 to 2.0.2.0. I use the template module a lot to build configs for my app. After updating, when I generate my templates, the data structure variables are being rendered as unicode strings. Versions: ansible 2.0.2.0 PyYAML==3.11 Jinja2==2.8 Example: File

Re: [ansible-project] need help in checking if a variable string is in an item string

2016-06-14 Thread Jerome Yanga
Thanks, Kai. You hit the nail on the head. If there is a doc on how to do this string manipulation, please share with me the URL. Regards, j On Tuesday, June 14, 2016 at 8:45:30 AM UTC-7, Kai Stian Olstad wrote: > > On 13. juni 2016 19:50, Jerome Yanga wrote: > > vars/main.yml > >

Re: [ansible-project] "TASK:" only showing "[command]"

2016-06-14 Thread Dana Christo
Thanks! Is there a way to change that? On Monday, June 13, 2016 at 1:39:15 PM UTC-7, Brian Coca wrote: > > No, in >=2.0 the task name by default does not include all the options > passed as it could disclose sensitive information. > > > -- > Brian Coca > -- You received this message

Re: [ansible-project] need help in checking if a variable string is in an item string

2016-06-14 Thread Kai Stian Olstad
On 13. juni 2016 19:50, Jerome Yanga wrote: vars/main.yml host_entries: Here you have host_entries - { srv_loc: 'ca', ip_addr: '10.1.1.1', host_aliases: 'ca-srv-01.example.com ca-srv-01' } - { srv_loc: 'ny', ip_addr: '10.2.1.1', host_aliases: 'ny-srv-01.example.com ny-srv-01' }

[ansible-project] Default mode for apt_repository module

2016-06-14 Thread stevew . work
I noticed today that the default mode is 420 for the apt_repository module which seems a little odd to me. I would think 640 or 644 would be more appropriate. Does anyone know the reason for setting the default mode to 420 (readable by owner, writable by group)? Thanks, Steve -- You

[ansible-project] Trying to recreate an if statement inside a for loop with ansible

2016-06-14 Thread Chris Shelton
So I have an on-line form in ansible tower that lets people pick a group to included in. I'm trying to set it up so they can pick multiple groups, but I'm having a tough time writing the logical checks I need. In any other programming language I could load the array and write a for loop to go

[ansible-project] "when" condition in handler is not honored

2016-06-14 Thread Guy Matz
Hi! I have a "when: condition that works fine in "regular" tasks, but not in a handler . . . is that expected? So I'm using a notify, then at the end of the handler task I have a when condition. The notification works, but it always triggers, ever when the condition is false. Here's the

[ansible-project] Re: need help in checking if a variable string is in an item string

2016-06-14 Thread Jerome Yanga
I apologize for not providing the info below. version: 2.0.2.0 event: skipping: [ca-server1] => (item={u'host_aliases': u'ca-srv-01.example.com ca-srv-01', u'ip_addr': u'10.1.1.1', u'srv_loc': u'ca'}) => {"changed": false, "item": {"host_aliases": "ca-srv-01.example.com ca-srv-01",

[ansible-project] Re: need help in checking if a variable string is in an item string

2016-06-14 Thread Jerome Yanga
I apologize. I forgot to provide the following. ansible version: 2.0.2.0 event: skipping: [server1] => (item={u'host_aliases': u'ca-srv-01.example.com ca-srv-01', u'ip_addr': u'10.1.1.1',

[ansible-project] Re: Lineinfile append at EOF

2016-06-14 Thread Jason Gilfoil
Mona, I don't think you need the regexp parameter, just set 'insertafter: EOF' to get it to append at the end of the file. See for what works for me in one of my scripts: - name: add script exec to bashrc lineinfile: dest: /home/.bashrc state: present line: '.

Re: [ansible-project] Ansible raw module & Cisco WLC

2016-06-14 Thread Kai Stian Olstad
On 14. juni 2016 10:39, David Vávra wrote: Hi, have anyone been succesful with at least logging in to Cisco WLC device with Ansible? I'm not able to make it work, most probably because of extra (nonstandard) prompt for User: (Cisco Controller) User: xxx Password:** (Cisco

Re: [ansible-project] mail using ansible

2016-06-14 Thread Kai Stian Olstad
On 14. juni 2016 08:03, Abhishek Bandari wrote: *email.yml* --- - hosts: localhost tasks: - name: sending mail mail: host: "smtp.gmail.com" port: 25 username: "xxx...@gmail.com" password: "x" to:

Re: [ansible-project] using pam_limits module in Ansible 2.1 errors

2016-06-14 Thread Kai Stian Olstad
On 14. juni 2016 01:42, Fong Yang wrote: TASK [system_configs : pam_limits] * fatal: [10.0.107.1]: FAILED! => {"failed": true, "msg": "module (pam_limits) is missing interpreter line"} fatal: [10.0.97.1]: FAILED! => {"failed": true, "msg":

[ansible-project] mail using ansible

2016-06-14 Thread Abhishek Bandari
*email.yml* --- - hosts: localhost tasks: - name: sending mail mail: host: "smtp.gmail.com" port: 25 username: "xxx...@gmail.com" password: "x" to: "x...@gmail.com" subject: "Ansible-report" body:

[ansible-project] Re: Serial: usage across multiple plays

2016-06-14 Thread Jason Gilfoil
After working on it some more, I realized that I can't easily just call my roles in the rolling-update.yml because I still have the limitation of needing to apply certain roles to certain hosts and that would require the start of a new play within the playbook which would break the serial

[ansible-project] Re: win_package uninstall example?

2016-06-14 Thread Trond Hindenes
Disabling UAC will have no effect. Any session coming in thru WinRM is by default elevated. As Jon writes, some packages are simply difficult/super-hard/impossible to uninstall in an unattended way. On Saturday, June 11, 2016 at 9:21:21 PM UTC+2, Bob Tanner wrote: > > Uninstalling Windows

Re: [ansible-project] Re: Ansible raw module & Cisco WLC

2016-06-14 Thread David Vávra
I believe that authentication based on RSA key-pair cannot be used with Cisco WLC firmware. Or can be? 2016-06-14 12:27 GMT+02:00 Christoph Wegener : > Have you tried using RSA key pairs instead of username/password? > > On Tuesday, June 14, 2016 at 6:39:43 PM UTC+10, David

[ansible-project] Re: Ansible raw module & Cisco WLC

2016-06-14 Thread Christoph Wegener
Have you tried using RSA key pairs instead of username/password? On Tuesday, June 14, 2016 at 6:39:43 PM UTC+10, David Vávra wrote: > > Hi, have anyone been succesful with at least logging in to Cisco WLC > device with Ansible? I'm not able to make it work, most probably because of > extra

Re: [ansible-project] Question about using the expect module

2016-06-14 Thread Sher Chowdhury
Hi Matt, That didn't work for me because I am using an older version of ansible, and I think what you described is for version 2.1+ However your suggestion made me realize that my understanding of how the expect module works was fundamentally wrong to begin with. I now figured out what I

[ansible-project] Ansible raw module & Cisco WLC

2016-06-14 Thread David Vávra
Hi, have anyone been succesful with at least logging in to Cisco WLC device with Ansible? I'm not able to make it work, most probably because of extra (nonstandard) prompt for User: (Cisco Controller) User: xxx Password:** (Cisco Controller) > Thanks for any advice on this. -- DV

[ansible-project] Re: Lineinfile append at EOF

2016-06-14 Thread Mona Gopal
Hi All, I figured out that the below works to append to a file, - name: Write redis details to file local_action: lineinfile dest={{ third_party_dest_path }} line=redis state=present create=yes However, i am unable to append the registered variable value to the file - name: Write redis