Re: [ansible-project] ec2_vol_facts examples?

2016-10-01 Thread Christopher Stobie
You can find out what is contained using debug.

On Oct 1, 2016 6:23 PM,  wrote:

> I need to go through my EC2 fleet and ensure certain tags are applied on
> ebs volumes. I have a conformance Playbook that goes through all the db
> nodes.
>
> ansible-playbook -i ec2.py -l tag_role_db db.yml
>
> I'm a little uncertain how I'd go through each host and find all attached
> volumes and then use ec2_tag to ensure tags.
>
> I think I can use ec2_vol_facts:
>
> - name: gather volume facts
>   ec2_vol_facts:
>filters: instance-id: {{ ec2_id }}
>
> But I'm not sure what's returned or how to use that as a with_items.
>
> Hoping to find some examples or some pointers.
>
> --
> 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/f8b60ae0-d5ac-4ec4-a754-0deea8cf1b15%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/CAHFHBDpwrRCD%2B%3DS3woP42rKytcoOJFwxK4Pkd50C%2B6ahC-%3DR_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Cisco IOS backup and write to file with timestamp

2016-10-01 Thread Peter Sprygada
Hi James,

This should accomplish what you are trying to do:

https://gist.github.com/privateip/d0fd3c6459c5e1a4c1f9dceeb018b109

Peter



On Fri, Sep 30, 2016 at 8:44 PM, James Baird  wrote:

> I looked into going that route but the concern is that is only available
> in 2.2 and I may have a hard time pushing the team to upgrade Ansoble to
> facilitate that change when we will be using this in production.
>
> --
> 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/7561f2e8-004b-48e0-8f73-9e385f55e1b3%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/CAEkdrMhZhRK8xEKFWPzXDG_Qzn1Tfe%2B-PaLR51b7CvJmVO-SxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] include_vars and include before hosts play i need to implement

2016-10-01 Thread pinky
Hi,

I have created my own custom library , i added my custom library in the 
common folder of my repository.In that i need to pass variables 
dyanamically .Its a confidential password,so iam using "vault" in ansible.

  In that my requirement is how to pass include_vars in the tasks\main.yml 
before hosts.

e.g: mytasks.yml
  - include_vars: sample_vault.yml
  - include: sample_tasks.yml
  - hosts: localhost
tasks:
  name: "free task"
  command: ls -a

my directory structure like this:

  myfolder
- common 
-library   
   -my file.py
- sample_tasks.yml

- mytasks
-mytasks.yml(my main master playbook file)
-sample_vault.yml  (note:i create this using vault for confidential 
purpose)
- roles
   -myrole


Here i need to run sample_tasks file using a variables passed in 
sample_vault.yml file before i execute the hosts tasks using ansible.If i 
use extra variable means password is visible so i dont need that.

When i use include_vars in my tasks/main.yml file, it shows the following 
error:

"ERROR! 'include_vars' is not a valid attribute for a Play"




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/ebf24244-84dc-4bfe-b9c5-689525714178%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] ec2_vol_facts examples?

2016-10-01 Thread mrz
I need to go through my EC2 fleet and ensure certain tags are applied on 
ebs volumes. I have a conformance Playbook that goes through all the db 
nodes.

ansible-playbook -i ec2.py -l tag_role_db db.yml

I'm a little uncertain how I'd go through each host and find all attached 
volumes and then use ec2_tag to ensure tags.

I think I can use ec2_vol_facts:

- name: gather volume facts
  ec2_vol_facts:
   filters: instance-id: {{ ec2_id }}  

But I'm not sure what's returned or how to use that as a with_items.

Hoping to find some examples or some pointers. 

-- 
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/f8b60ae0-d5ac-4ec4-a754-0deea8cf1b15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: How to have windows configured with ansible automatically

2016-10-01 Thread Sesh
On the SoftLayer there is an option for selecting a post provisioning 
script, where you can provide the set of WinRM commands to run after VM 
provisioned.


On Monday, April 4, 2016 at 4:29:36 PM UTC+10, Deepa Yr wrote:
>
> Hi
>
> Thanks for your response. I am using Windows 2012 R2 standard edition. 
> Without running the ConfigureRemotingForAnsible.ps1, I am not able to 
> connect to windows machine from Ansible controller. We are provisioning 
> machines on soft layer. Need to see whether an option/permission to create 
> a template is available with us or not. So looking for some option to get 
> the script run once the machine is provisioned. Tried using pywinrm , but 
> that needs some winrm variables to set , so the connection happens through 
> python.
>
> On Sunday, April 3, 2016 at 8:47:55 PM UTC+5:30, J Hawkesworth wrote:
>>
>> Hi,
>>
>> You don't mention which version(s) of windows you are using.  I think 
>> Server 2012 R2 may actually be configured for WinRM connections by default, 
>> so you might be able to connect without first running 
>> ConfigureRemotingForAnsible.ps1
>>
>> Also if you are using AWS see this 
>> https://www.ansible.com/blog/easily-provision-windows
>>
>> I get round this by using a vmware template with a run once script which 
>> runs ConfigureRemotingForAnsible.ps1 when the virtual machine is first 
>> created from the template.
>>
>> I believe you can also create an autorun xml file and add it to the root 
>> of the windows ISO which allows for a fully automated installation of 
>> windows from ISO but I have not tried this myself.
>>
>> Hope this helps,
>>
>> Jon
>>
>>
>>
>> On Friday, 1 April 2016 05:45:18 UTC+1, Deepa Yr wrote:
>>>
>>> Hi
>>>
>>> My requirement is  Provision a windows machine and run the 
>>> playbooks without manual intervention. In this case, we cannot run the 
>>> playbooks as windows is not configured for ansible. ie 
>>> ConfigureRemotingForAnsible.ps1 is not executed on windows machine. 
>>>
>>> Is there a way to connect to windows machine from ansible control 
>>> machine and run the powershell script, after that playbooks can be run.
>>>
>>> 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/54b933d0-4bff-489c-b8a6-2572d87ccd66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] how to use regex in copy or other module

2016-10-01 Thread 郭大瞎
I need to copy files from managed node to control machines.
A machine's tomcat path : /usr/local/tomcat-aux
B machine's tomcat path : /usr/local/tomcat-hk
actually there is not only these two instance. 
so I've tried below methods, but failed. 

 name: copy file to tomcat path
 copy: src=/deploy/a.conf  dest=/usr/local/tomcat*/

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/c2ff7c07-e9ff-41b4-91a7-91e44c38210a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] unable to detect ubuntu flavour ?

2016-10-01 Thread Mike Christofilopoulos
when gathering facts from a server, ubuntu release version comes back as NA.
Has anyone experienced this ?


from my server

```
No LSB modules are available.
Distributor ID: Ubuntu
Description:   Ubuntu 14.04.5 LTS
Release:   14.04
Codename:   trusty
```

but ansible reports ubuntu release as NA

```
ansible all  -l server -m setup -a 'filter=ansible_distribution_release'
server | SUCCESS => {
"ansible_facts": {
"ansible_distribution_release": "NA"
},
"changed": false
}
```

Ansible version:

```
ansible 2.1.1.0
  config file = /Users/mchristof/di/ansible/ansible.cfg
  configured module search path = Default w/o overrides
```

python version on the server

```
Python 2.7.11
```

-- 
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/cf12e023-1872-4acc-a19f-46e32cffb62e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: Re: ansible user module change passwd

2016-10-01 Thread Kai Stian Olstad

On 01. okt. 2016 04:24, hzj...@foxmail.com wrote:


thanks for ur advice,  i have aix and linux,   i wrote the playbook based on ur 
reply,  it works ,  but i think it's too long, is there a better way to rewrite 
this ?


In my opinion it's not long, you could but the code in it's one file and 
use include if you would like the playbook to have less code.




---
- name: test
  hosts: all
  gather_facts: true

  tasks:
   - name: Get information about the user for linux
 getent:
   key=foo
   database=passwd
   fail_key=false
 register: user_info_linux
 when: ansible_system == 'Linux'
   - debug: var=user_info_linux

   - name: Get information about the user for aix
 command: "lsuser foo"
 ignore_errors: yes
 register: user_info_aix
 when: ansible_system == 'AIX'
   - debug: var=user_info_aix

   - name: change pwd for linux
 command: uname -a
 when: ansible_system == 'Linux' and 
user_info_linux.ansible_facts.getent_passwd.foo != None

   - name: change pwd for aix
 command: uname -a
 when: ansible_system == 'AIX' and user_info_aix.stdout != ""


The other option is to use grep/egrep on /etc/passwd, the you can use 
the same code on AIX and Linux. I think AIX has egrep.


tasks:
  - Name get user
shell: egrep "^{{ user }}:" /etc/passwd
register: user_info

  - name: Change passwd
command: 
when: user_info.rc == 0

--
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/6c6b3958-5bed-0478-971c-3f34cb138312%40olstad.com.
For more options, visit https://groups.google.com/d/optout.