[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 != "root"
- set_fact: userdir="/root"
  when: ssh_keygen_user == "root"

- name: Check .ssh dir
  file: path={{ userdir }}/.ssh state=directory mode=0700 owner={{ 
ansible_user }} group={{ ansible_user }}

when playing this, if fails because "path": "/home//.ssh", so obviously i'm 
not passing the right values. could you help out please? thanks in 
adavance, P.


-- 
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/44b3de9d-3240-425d-862a-009db676e1a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 to 
access to the SSH, there is no way in the host_list in the python script to 
pass port for each host?


On Tuesday, June 14, 2016 at 11:37:49 PM UTC+1, Matt Martz wrote:
>
> 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 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 different ports)
>> But when I run the script I get a error that ansible couldn't connect to 
>> the server:
>>
>> This is the error i'm getting:
>> UP ***
>> FAILED ***
>> DOWN *
>> {
>>   "_meta": {
>> "hostvars": {
>>   "10.24.20.126": {
>> "ansible_host": "10.24.20.126" >>> Failed to connect to the host 
>> via ssh.
>>
>> This is the full json I'm sending to the host_list variable in the python 
>> script
>> js = {"group": {"hosts": ["10.24.20.126", "10.24.20.127"], "vars": 
>> {"ansible_user": "user", "ansible_port": 22}}, "_meta": {"hostvars": 
>> {"10.24.20.126": {"ansible_host": "10.24.20.126", "ansible_user": "user", 
>> "ansible_port": "22"}, "10.24.20.127": {"host_specific_var": "foo"
>>
>> And this is the error i'm getting:
>>
>> UP ***
>> FAILED ***
>> DOWN *
>> {
>>   "_meta": {
>> "hostvars": {
>>   "10.24.20.126": {
>> "ansible_host": "10.24.20.126" >>> Failed to connect to the host 
>> via ssh.
>>
>>
>> This ansible can connect to this server if i ping it using ansible 
>> (ansible -m ping 10.24.20.126)
>>
>> 10.24.20.126 | SUCCESS => {
>> "changed": false,
>> "ping": "pong"
>> }
>>
>> the python script I took from here:
>> https://github.com/ansible/ansible/blob/devel/examples/scripts/uptime.py
>>
>> And I just send into the host_list variable the JSON.
>>
>> Any thought of why my script doesn't work ?
>>
>> Thank you evreyone
>>
>> -- 
>> 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/33aa946b-feaa-42f2-8465-567f507b1ced%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> -- 
> Matt Martz
> @sivel
> sivel.net
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5619c099-bc74-4f48-a345-0635a66342be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 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 different ports)
> But when I run the script I get a error that ansible couldn't connect to
> the server:
>
> This is the error i'm getting:
> UP ***
> FAILED ***
> DOWN *
> {
>   "_meta": {
> "hostvars": {
>   "10.24.20.126": {
> "ansible_host": "10.24.20.126" >>> Failed to connect to the host
> via ssh.
>
> This is the full json I'm sending to the host_list variable in the python
> script
> js = {"group": {"hosts": ["10.24.20.126", "10.24.20.127"], "vars":
> {"ansible_user": "user", "ansible_port": 22}}, "_meta": {"hostvars":
> {"10.24.20.126": {"ansible_host": "10.24.20.126", "ansible_user": "user",
> "ansible_port": "22"}, "10.24.20.127": {"host_specific_var": "foo"
>
> And this is the error i'm getting:
>
> UP ***
> FAILED ***
> DOWN *
> {
>   "_meta": {
> "hostvars": {
>   "10.24.20.126": {
> "ansible_host": "10.24.20.126" >>> Failed to connect to the host
> via ssh.
>
>
> This ansible can connect to this server if i ping it using ansible
> (ansible -m ping 10.24.20.126)
>
> 10.24.20.126 | SUCCESS => {
> "changed": false,
> "ping": "pong"
> }
>
> the python script I took from here:
> https://github.com/ansible/ansible/blob/devel/examples/scripts/uptime.py
>
> And I just send into the host_list variable the JSON.
>
> Any thought of why my script doesn't work ?
>
> Thank you evreyone
>
> --
> 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/33aa946b-feaa-42f2-8465-567f507b1ced%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Matt Martz
@sivel
sivel.net

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v_R-E14ZEJbBhv2GsQO8HJrYuowijEp7JQ5BEc%2B99nC%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[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 different ports)
But when I run the script I get a error that ansible couldn't connect to 
the server:

This is the error i'm getting:
UP ***
FAILED ***
DOWN *
{
  "_meta": {
"hostvars": {
  "10.24.20.126": {
"ansible_host": "10.24.20.126" >>> Failed to connect to the host 
via ssh.

This is the full json I'm sending to the host_list variable in the python 
script
js = {"group": {"hosts": ["10.24.20.126", "10.24.20.127"], "vars": 
{"ansible_user": "user", "ansible_port": 22}}, "_meta": {"hostvars": 
{"10.24.20.126": {"ansible_host": "10.24.20.126", "ansible_user": "user", 
"ansible_port": "22"}, "10.24.20.127": {"host_specific_var": "foo"

And this is the error i'm getting:

UP ***
FAILED ***
DOWN *
{
  "_meta": {
"hostvars": {
  "10.24.20.126": {
"ansible_host": "10.24.20.126" >>> Failed to connect to the host 
via ssh.


This ansible can connect to this server if i ping it using ansible (ansible 
-m ping 10.24.20.126)

10.24.20.126 | SUCCESS => {
"changed": false,
"ping": "pong"
}

the python script I took from here:
https://github.com/ansible/ansible/blob/devel/examples/scripts/uptime.py

And I just send into the host_list variable the JSON.

Any thought of why my script doesn't work ?

Thank you evreyone

-- 
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/33aa946b-feaa-42f2-8465-567f507b1ced%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 multiple 
ansible-playbook processes running.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a9c16113-ff9a-4e31-ba5b-574ba6331049%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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, please share with me the URL. 
>
> I have just picked it up, but I guess it's a Python string method 
> https://docs.python.org/2.7/library/stdtypes.html?highlight=split#str.split 
>
> Maybe all the Python string methods work, hopefully someone else can 
> shed some light on that. 
>
>
> -- 
> 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/402c039c-ffd3-4879-a526-c0d1b0e31df6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 install/uninstall- 
have a look at 
http://download.microsoft.com/download/7/8/d/78da8ec9-8801-42e5-89e5-3809386f1316/Silverlight%20Deployment%20Guide.doc

I suspect the switch you're looking for is "/qu" (silent uninstall).


On Tuesday, June 14, 2016 at 3:58:07 AM UTC-7, Trond Hindenes wrote:
>
> 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 packages via Ansible is hard.  Is this normal? I 
>> feeling like I'm missing something fundamental using Ansible to manage 
>> Windows.
>>
>> Here's my playbook.
>>
>> - name: disable UAC pop up for Administrators
>>win_regedit:
>> key: HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System
>> value: ConsentPromptBehaviorAdmin
>> data: 
>> datatype: dword
>>
>> - name: remove packages (win_package)
>>   win_package: >
>> name="Microsoft Silverlight"
>> path="C:\\Program Files\\Microsoft Silverlight\\sllauncher.exe"
>> product_id="{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}"
>> state="absent"
>>
>> The task hangs and eventually timeout.  Started to get desperate and 
>> added these plays:
>>
>>   - name: disallow interactive services
>> win_regedit:
>> key: HKLM:\SYSTEM\CurrentControlSet\Control\Windows
>> value: NoInteractiveServices
>> data: 0001
>> datatype: dword
>>
>>   - name: stop Interactive Services Detection
>> win_service:
>> name: 'UI0Detect'
>> start_mode: manual
>> state: stopped
>>
>> Still the uninstall hangs and times out.
>>
>> When I try uninstalling Silverlight via:
>>
>> msiexec /uninstall "{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}" /l 
>> C:\logs\zzz.log
>>
>> I get the "Windows Installer" dialog prompting to confirm the uninstall. 
>> Click "Yes" and Silverlight is uninstalled. Nothing of much value in the 
>> C:\logs\zzz.log file.
>>
>> msiexec /uninstall "{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}" /l 
>> C:\logs\zzz.log \quiet
>>
>> Uninstalls without any dialog. Nothing of much value in the logs.
>>
>> How do I duplicate this uninstall with win_package?
>>
>> I cannot seem to get win_msi to work either. 
>>
>> I am brute forcing things with script :-(
>>
>> - name: remove packages (powershell script)
>>   script: files/remove-package.ps1
>>
>> remote-package.ps1
>>
>> $app = Get-WmiObject -Class Win32_Product -Filter "IdentifyingNumber = 
>> '{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}'"
>> $app.Uninstall()
>>
>

-- 
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/0c213394-1d1d-4a89-86c3-d06a5706f5e1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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: "'peoplesoft-nonprod-servers' in group_names" }
>   - {role: ps-tuxedo, when: "'nonprod-appservers' in group_names" }
>   .. etc
>   post_tasks:
>   - name: enable node in the F5 Pool


Not the way i'd prefer to do it(serial working across playbook includes) 
but it'll do the job. If anyone has any alternatives or thoughts, i'd still 
be happy to hear about them.

P.S. In case anyone comes across this post trying to do the same thing, 
there's a bug with serial:  where percentages aren't calculated correctly 
when the host number is below 1. To be corrected in a coming version 
release.

On Tuesday, June 14, 2016 at 8:34:23 AM UTC-4, Jason Gilfoil wrote:
>
> 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 
> execution. The only way I can see forward here is to tag the roles and use 
> --skip-tags: when calling the playbook and exclude the roles which don't 
> need to be applied everywhere. Feels kinda like a hacky way to accomplish 
> it though.
>
> On Monday, June 13, 2016 at 4:07:04 PM UTC-4, Jason Gilfoil wrote:
>>
>> I'm trying to write a rolling-update.yml playbook that calls other 
>> playbooks and makes use of the serial: attribute.
>>
>> It goes something like this:
>>
>> rolling-update.yml:
>>
>> - hosts: nonprod-app-servers
>>>   serial: "30%"
>>>   pre_tasks:
>>>   - name: disable node in the F5 Pool
>>> - include: peoplesoft.yml
>>>   post_tasks:
>>>   - name: enable node in the F5 Pool
>>
>>
>>
>> peoplesoft.yml  playbook calls multiple roles with different host targets
>>
>> - hosts: peoplesoft-nonprod-servers
>>>   roles:
>>>   - ps-common
>>> - hosts: nonprod-app-servers:nonprod-unixprcs-servers
>>>   roles:
>>>   - ps-tuxedo
>>> - hosts: nonprod-app-servers
>>>   roles:
>>>   - ps-app-domains
>>
>>
>> ... and so on...
>>
>>
>> What I want is to call rolling-update.yml and target a cluster so that it 
>> runs through the entire rolling-update playbook on 30% of the targeted 
>> group at a time. However, as I understand it, there's two problems with 
>> this. 
>>
>> A) you can't apply serial: to an included playbook and 
>> B) even if you could, it would be a different play and starts the next 
>> set of hosts before moving on to the next play.
>>
>> I'm kinda hoping my only recourse isn't to explicitly call all my roles 
>> in the rolling-update playbook, since I have a list of 7 roles that apply 
>> to various parts of the infrastructure and that list is growing weekly. I'd 
>> prefer to just reuse the existing peoplesoft.yml playbook and call that 
>> from other playbooks.
>>
>> Appreciate any thoughts/insight, even if only to tell me i'm hosed and to 
>> suck it up stop reusing the peoplesoft.yml playbook.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c68b1af3-bb79-4774-8d80-5bd9858c9956%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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
https://docs.python.org/2.7/library/stdtypes.html?highlight=split#str.split

Maybe all the Python string methods work, hopefully someone else can 
shed some light on that.



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


[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, 2016 at 1:02:51 PM UTC-5, jamesv...@gmail.com wrote:
>
> 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
>   gather_facts: false
>   roles:
> - all_servers
> *- {role: production_server, when: prod_fact.find('P')}*
>
> The error I am getting is fatal: [hostname]: FAILED! => {"failed": true, 
> "msg": "ERROR! The conditional check '{{prod_fact}}.find('P')' failed. The 
> error was: ERROR! template error while templating string: expected token 
> ',', got 'string'"}
>
> In order to get the stdout_variable I am using *set_fact*
>
> ---
> - name: Check Env Type and Save it in Var=prod_fact
>   script: files/CheckEnvType.ps1 -hostname {{inventory_hostname}}
>   register: result
> - set_fact:
> prod_fact: "{{result.stdout_lines | default('')}}"
>
>
>

-- 
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/32f65e07-39c0-42a1-a66a-aa873c388b5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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
  gather_facts: false
  roles:
- all_servers
*- {role: production_server, when: prod_fact.find('P')}*

The error I am getting is fatal: [hostname]: FAILED! => {"failed": true, 
"msg": "ERROR! The conditional check '{{prod_fact}}.find('P')' failed. The 
error was: ERROR! template error while templating string: expected token 
',', got 'string'"}

In order to get the stdout_variable I am using *set_fact*

---
- name: Check Env Type and Save it in Var=prod_fact
  script: files/CheckEnvType.ps1 -hostname {{inventory_hostname}}
  register: result
- set_fact:
prod_fact: "{{result.stdout_lines | default('')}}"


-- 
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/96400119-dfb4-42c8-b9f3-fbd90640d1d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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": 1, "count_tag": 
null, "ebs_optimized": false, "ec2_url": null, "exact_count": null, 
"group": null, "group_id": null, "id": null, "image": null, "instance_ids": 
["i-ba508d26", "i-bda01c21"], "instance_profile_name": null, 
"instance_tags": null, "instance_type": null, "kernel": null, "key_name": 
null, "monitoring": false, "network_interfaces": null, "placement_group": 
null, "private_ip": null, "profile": null, "ramdisk": null, "region": 
"us-east-1", "security_token": null, "source_dest_check": true, 
"spot_launch_group": null, "spot_price": null, "spot_type": "one-time", 
"spot_wait_timeout": "600", "state": "running", "tenancy": "default", 
"termination_protection": false, "user_data": null, "validate_certs": true, 
"volumes": null, "vpc_subnet_id": null, "wait": false, "wait_timeout": 
"300", "zone": null}, "module_name": "ec2"}, "msg": "No handler was ready 
to authenticate. 1 handlers were checked. ['HmacAuthV4Handler'] Check your 
credentials"}




it seems like it is happening because of environment variables not set 
properly but i have set the environment variables and still not working 
with environment variables set up in my .bashrc file.

-- 
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/7a9f6d41-5d2f-4407-a887-7670862522ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 with variables:
---
my_list:
- var1

Template file:
app.config.j2
'MYLIST': '{{my_list}}'

ansible command:
ansible localhost -m template -a "src=app.config.j2 dest=/tmp/app.config"

Contents of app.config:
'MYLIST': '[u'var1']'

What I used to get: (Version 1.9.1)
'MYLIST': '['var1']'

If I change my env file to be a string, then the file gets generated how it 
used to be.
---
my_list: "['var1']"


This also happens when I try creating dictionaries and nested dictionaries. 
Any ideas on what could be causing this, or how I can fix it?

TIA,
Henry

-- 
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/70e17746-cf11-4023-b1ad-83939d925af2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 
> > 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' } 
> >   - { srv_loc:  'co', ip_addr:  '10.3.1.1', host_aliases: 
> >   'co-srv-01.example.com co-srv-01' } 
> > 
> > tasks/main.yml 
> > --- 
> > 
> >   - name: checking location of server 
> > raw:  'echo "{{ ansible_hostname }}" | cut -f1 -d"-"' 
> > register: actual_loc 
> > 
> >   - name: adding entries in the hosts file 
> > lineinfile: 
> >backup:  yes 
> >create:  yes 
> >dest:  /etc/hosts 
> >group:  root 
> >line:  "{{item.ip_addr}} {{item.host_aliases}}" 
> >mode:  0644 
> >owner:  root 
> >state:  present 
> > when:  ( actual_loc.stdout_lines == item.srv_loc ) 
> > with_items:  "{{ hosts_entries }}" 
>
> But here you have hosts_entries, so one of them is a typo. 
>
> You could lose the raw by doing so in the when 
> when: ansible_hostname.split('-')[0] == item.srv_loc 
>
> -- 
> 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/c81efcbc-8a13-4c79-ac37-511b96f59894%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 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/3beee9ce-c0bb-4c30-bcba-4877ab5a8d25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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

2016-06-14 Thread Brian Coca
display_args_to_stdout in ansible.cfg


--
Brian Coca

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACVha7edpvWDgd%2B5YvbaduNRCTh1_RLW9buacrebN_aAmCkWpw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


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' }
  - { srv_loc:  'co', ip_addr:  '10.3.1.1', host_aliases:
  'co-srv-01.example.com co-srv-01' }

tasks/main.yml
---

  - name: checking location of server
raw:  'echo "{{ ansible_hostname }}" | cut -f1 -d"-"'
register: actual_loc

  - name: adding entries in the hosts file
lineinfile:
   backup:  yes
   create:  yes
   dest:  /etc/hosts
   group:  root
   line:  "{{item.ip_addr}} {{item.host_aliases}}"
   mode:  0644
   owner:  root
   state:  present
when:  ( actual_loc.stdout_lines == item.srv_loc )
with_items:  "{{ hosts_entries }}"


But here you have hosts_entries, so one of them is a typo.

You could lose the raw by doing so in the when
when: ansible_hostname.split('-')[0] == item.srv_loc

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


[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 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/dfd98057-e8dd-4260-8b0c-22d557df0c0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 through every element and if one of them doesn't exist, rewrite 
a binary variable that would be used in further logical checks. Something 
like this: 

groups = [group1, group2, group3, ... ] 
does_not_exist_check_variable = 0

for i = 1:length(groups)

if group(i) does not exist
   
does_not_exist_check_variable = 1

 end if

end
 

In ansible, the closest thing I can find to a for loop is with_item which 
in all of the text I've read so far implies that the command is to be used 
to supplement certain items into a configuration one after another. I've 
attempted to recreate my for loop and if statements like this: 

   - name: Create dne_check variable

set_fact: dne_check = 0

  - name: Get groups names

shell: item.value.access.find('{{ group_names }}')

register: all_group_names 

  - name: Check for blank group names

set_fact: dne_check = 1

with_items:" {{all_group_names}}"

when: item == -1


But it complains about my syntax at the last when statement. Any help on 
the matter would be greatly appreciated. 

-- 
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/ed54a82f-0bb6-4797-a152-597ea9b00a0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 handler:
- name: restart render
  supervisorctl:
name: "render"
state: restarted
  when: "'render' in group_names"

Any ideas?

Thanks a lot,
Guy

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


[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", "ip_addr": "10.1.1.1", 
"srv_loc": "ca"}, "skip_reason": "Conditional check failed", "skipped": 
true}

Regards,
j

On Monday, June 13, 2016 at 10:50:10 AM UTC-7, Jerome Yanga wrote:
>
> Here is what I have.
>
> vars/main.yml
> 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' }
>  - { srv_loc:  'co', ip_addr:  '10.3.1.1', host_aliases:  '
> co-srv-01.example.com co-srv-01' }
>
> tasks/main.yml
> ---
>
>  - name: checking location of server
>raw:  'echo "{{ ansible_hostname }}" | cut -f1 -d"-"'
>register: actual_loc
>
>  - name: adding entries in the hosts file
>lineinfile:
>   backup:  yes
>   create:  yes
>   dest:  /etc/hosts
>   group:  root
>   line:  "{{item.ip_addr}} {{item.host_aliases}}"
>   mode:  0644
>   owner:  root
>   state:  present
>when:  ( actual_loc.stdout_lines == item.srv_loc )
>with_items:  "{{ hosts_entries }}"
>
> I am trying to add the correct hosts entries based on the substring of a 
> hostname.  All items are being skipped at the moment due to '"skip_reason": 
> "Conditional check failed", "skipped": true'.  
>
> Please help.  :)
>
> Regards,
> j
>

-- 
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/1bd794b6-992a-48e1-8be8-020f784fdf3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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', u'srv_loc': u'ca'})  => {"changed": false, "item": 
{"host_aliases": "a-srv-01.example.com 

 ca-srv-01", 
"ip_addr": "10.1.1.1", "srv_loc": "ca"}, "skip_reason": "Conditional check 
failed", "skipped": true}

Regards,
j



On Monday, June 13, 2016 at 10:50:10 AM UTC-7, Jerome Yanga wrote:
>
> Here is what I have.
>
> vars/main.yml
> 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' }
>  - { srv_loc:  'co', ip_addr:  '10.3.1.1', host_aliases:  '
> co-srv-01.example.com co-srv-01' }
>
> tasks/main.yml
> ---
>
>  - name: checking location of server
>raw:  'echo "{{ ansible_hostname }}" | cut -f1 -d"-"'
>register: actual_loc
>
>  - name: adding entries in the hosts file
>lineinfile:
>   backup:  yes
>   create:  yes
>   dest:  /etc/hosts
>   group:  root
>   line:  "{{item.ip_addr}} {{item.host_aliases}}"
>   mode:  0644
>   owner:  root
>   state:  present
>when:  ( actual_loc.stdout_lines == item.srv_loc )
>with_items:  "{{ hosts_entries }}"
>
> I am trying to add the correct hosts entries based on the substring of a 
> hostname.  All items are being skipped at the moment due to '"skip_reason": 
> "Conditional check failed", "skipped": true'.  
>
> Please help.  :)
>
> Regards,
> j
>

-- 
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/b3078eed-74a6-4c1d-9ecd-306cd920d1b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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: '. /home/.profile-custom'
insertafter: EOF


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

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/dca545a3-7137-4e64-84f3-4aa298240166%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 Controller) >


This looks like a interactive console, you can't use raw module for 
that, you'll have to use the expect module.


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


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: "x...@gmail.com"
 subject: "Ansible-report"
 body: "Hello, this is an e-mail. I hope you like it ;-)"

This code is fine...but im getting error like this...I tried 25,465.587
ports


According to the example in the documentation
https://docs.ansible.com/ansible/mail_module.html#examples
it's port 587.

And that's work for me.



[root@ansible-hyd ~]# ansible-playbook email.yml

PLAY [localhost]
***

TASK [setup]
***
ok: [localhost]

TASK [sending mail]

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg":
"Failed to send mail to server smtp.gmail.com on port 25: [Errno 101]
Network is unreachable", "rc": 1}


Do you get the same message with port 587?
If so, are port 587 open for outgoing connections?

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


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": "module
(pam_limits) is missing interpreter line"}
   fatal: [10.0.70.1]: FAILED! => {"failed": true, "msg": "module
(pam_limits) is missing interpreter line"}
 to retry, use: --limit @/etc/ansible/main.retry

What am I missing?  This is the task:

- pam_limits: domain=* limit_item=nofile limit_type=- value=65536


This work for me on Ansible 2.1, so it must be something local.

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


[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: "Hello, this is an e-mail. I hope you like it ;-)"

This code is fine...but im getting error like this...I tried 25,465.587 
ports

[root@ansible-hyd ~]# ansible-playbook email.yml

PLAY [localhost] 
***

TASK [setup] 
***
ok: [localhost]

TASK [sending mail] 

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": 
"Failed to send mail to server smtp.gmail.com on port 25: [Errno 101] 
Network is unreachable", "rc": 1}

NO MORE HOSTS LEFT 
*
to retry, use: --limit @email.retry

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



*How to configure...Help me from this..*.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6fee3dc6-66df-47c5-9c4c-a240c486547d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 
execution. The only way I can see forward here is to tag the roles and use 
--skip-tags: when calling the playbook and exclude the roles which don't 
need to be applied everywhere. Feels kinda like a hacky way to accomplish 
it though.

On Monday, June 13, 2016 at 4:07:04 PM UTC-4, Jason Gilfoil wrote:
>
> I'm trying to write a rolling-update.yml playbook that calls other 
> playbooks and makes use of the serial: attribute.
>
> It goes something like this:
>
> rolling-update.yml:
>
> - hosts: nonprod-app-servers
>>   serial: "30%"
>>   pre_tasks:
>>   - name: disable node in the F5 Pool
>> - include: peoplesoft.yml
>>   post_tasks:
>>   - name: enable node in the F5 Pool
>
>
>
> peoplesoft.yml  playbook calls multiple roles with different host targets
>
> - hosts: peoplesoft-nonprod-servers
>>   roles:
>>   - ps-common
>> - hosts: nonprod-app-servers:nonprod-unixprcs-servers
>>   roles:
>>   - ps-tuxedo
>> - hosts: nonprod-app-servers
>>   roles:
>>   - ps-app-domains
>
>
> ... and so on...
>
>
> What I want is to call rolling-update.yml and target a cluster so that it 
> runs through the entire rolling-update playbook on 30% of the targeted 
> group at a time. However, as I understand it, there's two problems with 
> this. 
>
> A) you can't apply serial: to an included playbook and 
> B) even if you could, it would be a different play and starts the next set 
> of hosts before moving on to the next play.
>
> I'm kinda hoping my only recourse isn't to explicitly call all my roles in 
> the rolling-update playbook, since I have a list of 7 roles that apply to 
> various parts of the infrastructure and that list is growing weekly. I'd 
> prefer to just reuse the existing peoplesoft.yml playbook and call that 
> from other playbooks.
>
> Appreciate any thoughts/insight, even if only to tell me i'm hosed and to 
> suck it up stop reusing the peoplesoft.yml playbook.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b32d8b27-24c5-4326-aab9-3becf007696c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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 packages via Ansible is hard.  Is this normal? I 
> feeling like I'm missing something fundamental using Ansible to manage 
> Windows.
>
> Here's my playbook.
>
> - name: disable UAC pop up for Administrators
>win_regedit:
> key: HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System
> value: ConsentPromptBehaviorAdmin
> data: 
> datatype: dword
>
> - name: remove packages (win_package)
>   win_package: >
> name="Microsoft Silverlight"
> path="C:\\Program Files\\Microsoft Silverlight\\sllauncher.exe"
> product_id="{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}"
> state="absent"
>
> The task hangs and eventually timeout.  Started to get desperate and added 
> these plays:
>
>   - name: disallow interactive services
> win_regedit:
> key: HKLM:\SYSTEM\CurrentControlSet\Control\Windows
> value: NoInteractiveServices
> data: 0001
> datatype: dword
>
>   - name: stop Interactive Services Detection
> win_service:
> name: 'UI0Detect'
> start_mode: manual
> state: stopped
>
> Still the uninstall hangs and times out.
>
> When I try uninstalling Silverlight via:
>
> msiexec /uninstall "{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}" /l 
> C:\logs\zzz.log
>
> I get the "Windows Installer" dialog prompting to confirm the uninstall. 
> Click "Yes" and Silverlight is uninstalled. Nothing of much value in the 
> C:\logs\zzz.log file.
>
> msiexec /uninstall "{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}" /l 
> C:\logs\zzz.log \quiet
>
> Uninstalls without any dialog. Nothing of much value in the logs.
>
> How do I duplicate this uninstall with win_package?
>
> I cannot seem to get win_msi to work either. 
>
> I am brute forcing things with script :-(
>
> - name: remove packages (powershell script)
>   script: files/remove-package.ps1
>
> remote-package.ps1
>
> $app = Get-WmiObject -Class Win32_Product -Filter "IdentifyingNumber = 
> '{89F4137D-6C26-4A84-BDB8-2E5A4BB71E00}'"
> $app.Uninstall()
>

-- 
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/5305be3f-804f-4d0c-b0e5-92e1bce7a2b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 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 Controller) >
>>
>> Thanks for any advice on this.
>>
>> --
>> DV
>>
>>
>> --
> 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/xpHZ7JFEhw4/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/c847dffd-6f4c-49a7-813f-e5f652763cfc%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/CAGOgyxhhtPUdDZUYAr17ehsLXQUEZFkZcPMkgMXzCy_j%3DtfN8w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[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 (nonstandard) prompt for User: 
>
> (Cisco Controller)
> User: xxx
> Password:**
> (Cisco Controller) >
>
> Thanks for any advice on this.
>
> --
> DV
>
>
>

-- 
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/c847dffd-6f4c-49a7-813f-e5f652763cfc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 needed to do. In my case I'm doing an unattended (silent) 
upgrade of confluence, and I am using:


- expect:
command: /tmp/atlassian-confluence-5.10.0-x64.bin
responses:
  "This will install Confluence": o
  "Upgrade an existing Confluence installation": '3'
  "Existing installation directory": /opt/atlassian/confluence
  "Back up Confluence home": n
  "List of modifications made within Confluence directories.": ' '
  "Do you want to proceed": u
timeout: 300

I now realize that "responses" operates a bit like a case statement, 
whereas I thought it was working as a dumb sequence of inputs.

Thank you for your help. 

Kind regards,
Sher 





 

On Monday, June 13, 2016 at 5:58:19 PM UTC+1, Matt Martz wrote:
>
> Expect works off of text to expect and a string to send.  I tend to think 
> of them as questions and answers.
>
> You are required to provide both.  At minimum I guess you could do 
> something like:
>
> - expect:
> command: /path/to/custom/command
> responses:
> ".*": 
> - b
> - d
> - y
>
> That will answer with those letters, in order, based on any match.
>
> On Mon, Jun 13, 2016 at 11:28 AM, Sher Chowdhury  > wrote:
>
>> I have an interactive command that prompts me enter a series of letters, 
>> b, d, and y. I was wondering if it is possible to run something like this:
>>
>> - expect:
>> command: /path/to/custom/command
>> responses:
>> - b
>> - d
>> - y
>>
>> I don't need to do any regex matching, I just need to pass these letters in.
>>
>> Although I would like to do regex matching if that is possible with my 
>> version of ansible, by the way, my verion of ansible is:
>>
>> $ ansible --version
>> ansible 2.0.2.0
>>   config file = /etc/ansible/ansible.cfg
>>   configured module search path = Default w/o overrides
>>
>> Thanks Sher
>>
>> -- 
>> 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/ab584dff-8c7a-431e-bbc5-5f637cf47323%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Matt Martz
> @sivel
> sivel.net
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b0734974-bf01-43ae-82f1-41a476018c2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[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


-- 
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/a8f369cb-59d6-4f36-8761-1922e0470060%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.