Re: [ansible-project] BUG? 'AnsibleSequence' object has no attribute 'strip'

2018-02-13 Thread Kai Stian Olstad

On 14.02.2018 00:30, John Harmon wrote:
I don't know if I have a syntax issue or a bug.  Thought before filing 
a
bug I would see what you guys thought.  I have a bunch of 
roles/playbooks I

wish to execute against new servers.  Here is what I have come up with.
ansible-2.4.3.0-1.el7.ans.noarch


Playbook:
---
- hosts: "{{ host }}"

  roles:
- ansible_dependencies
- aliases






  import_playbook:
- /playbooks/one-offs/bash_history.yml -e host= "{{ host }}"
- /playbooks/one-offs/dmesg_timestamps.yml -e host= "{{ host }}"
- /playbooks/one-offs/grub_cmdline.yml -e host= "{{ host }}"


import_playbook is not a directive for a play, since it's a file with 
one or more play it's a directive on the top level.

So you need a dash in front and move it all the way to the left.

import_playbook doesn't take a list of playbook files, a little hint is 
that it's _playbook not _playbooks.


-e is misplaced, -e is a command line option so remove that.

It's not allowed to have space in-front or after the equal sign in 
Ansible yaml syntax.


So try

- import_playbook: /playbooks/one-offs/bash_history.yml host="{{ host 
}}"
- import_playbook: /playbooks/one-offs/dmesg_timestamps.yml host="{{ 
host }}"

...
...


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


[ansible-project] Re: Yaml statement over multiple lines.

2018-02-13 Thread flowerysong
On Tuesday, February 13, 2018 at 7:25:24 AM UTC-5, mail.ph...@gmail.com 
wrote:
>
>
> How should I split this dest: statement into multiple lines ?
>
> - copy:
> content: "{{ config.stdout[0] }}"
> *dest: "{{ backup_root }}/{{ inventory_hostname }}/dhcp_leases_{{ 
> ansible_date_time.year }}{{ ansible_date_time.month }}{{ 
> ansible_date_time.day }}{{ ansible_date_time.hour }}{{ 
> ansible_date_time.minute }}{{ ansible_date_time.second }}"*
>

There are multiple ways to do it, but I'd go for something like this:
dest: "{{ [ backup_root, inventory_hostname, 'dhcp_leases_' ~
  ('%Y%m%d%H%M%S' | strftime) ] | join('/') }}"

(If using the time from the facts is important, you can do 
"strftime(ansible_date_time.epoch)" instead of the plain invocation.)

-- 
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/80449d9d-463f-4436-8ab5-a3dac2d6aa89%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: do_dictsort() got an unexpected keyword argument 'reverse'

2018-02-13 Thread Martin Cigorraga
Matt,

I can't share the details as it wasn't me the one who made the 
implementation, but we were able to adapt the Jinja2 2.10 filter plugin by 
converting it to an Ansible v2 filter plugin.

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/3d88dbd1-a243-4109-b16f-46a241b19284%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: BUG? 'AnsibleSequence' object has no attribute 'strip'

2018-02-13 Thread John Harmon
If I comment out the import_playbook: section down, it works so the 
issue is in the latter-half still trying to narrow down

-- 
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/1f251bc8-0863-467e-9c42-c063b96977ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] BUG? 'AnsibleSequence' object has no attribute 'strip'

2018-02-13 Thread John Harmon
I don't know if I have a syntax issue or a bug.  Thought before filing a 
bug I would see what you guys thought.  I have a bunch of roles/playbooks I 
wish to execute against new servers.  Here is what I have come up with.
ansible-2.4.3.0-1.el7.ans.noarch


Playbook:
---
- hosts: "{{ host }}"

  roles:
- ansible_dependencies
- aliases
- cpu_utilization
- dns_update
- role: nagios
  install: yes
- password_policy
- sudoers
- disable_NetworkManager
- grub_cmdline_oracle_tuning
- ldap_users
- ps1_customize
- vim_customize

  import_playbook:
- /playbooks/one-offs/bash_history.yml -e host= "{{ host }}"
- /playbooks/one-offs/dmesg_timestamps.yml -e host= "{{ host }}"
- /playbooks/one-offs/grub_cmdline.yml -e host= "{{ host }}"
- /playbooks/one-offs/update_gitlab_scripts.yml -e host= "{{ host }}"
- /playbooks/one-offs/grub_timeout.yml -e host= "{{ host }}"
- /playbooks/one-offs/update_sssd_ddns.yml -e host= "{{ host }}"
- /playbooks/one-offs/authconfig_cleanup.yml -e host= "{{ host }}"
- /playbooks/one-offs/change_timezone.yml -e host= "{{ host }}"
- /playbooks/one-offs/firefox_no_gui.yml -e host= "{{ host }}"
- /playbooks/one-offs/tcp_tuning.yml -e host= "{{ host }}"



*ERROR! Unexpected Exception, this is probably a bug: 'AnsibleSequence' 
object has no attribute 'strip'*
Details
ansible:/playbooks # ansible-playbook new_server_setup.yml -e 
host=ansible-oel6 -vvv
ansible-playbook 2.4.3.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u
'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible-playbook
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 
20150623 (Red Hat 4.8.5-16)]
Using /etc/ansible/ansible.cfg as config file
Parsed /etc/ansible/inventory/hosts inventory source with ini plugin
ERROR! Unexpected Exception, this is probably a bug: 'AnsibleSequence' 
object has no attribute 'strip'
the full traceback was:

Traceback (most recent call last):
  File "/bin/ansible-playbook", line 106, in 
exit_code = cli.run()
  File "/usr/lib/python2.7/site-packages/ansible/cli/playbook.py", line 122, 
in run
results = pbex.run()
  File 
"/usr/lib/python2.7/site-packages/ansible/executor/playbook_executor.py", 
line 82, in run
pb = Playbook.load(playbook_path, variable_manager=self.
_variable_manager, loader=self._loader)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/__init__.py", 
line 54, in load
pb._load_playbook_data(file_name=file_name, variable_manager=
variable_manager)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/__init__.py", 
line 99, in _load_playbook_data
pb = PlaybookInclude.load(entry, basedir=self._basedir, variable_manager
=variable_manager, loader=self._loader)
  File 
"/usr/lib/python2.7/site-packages/ansible/playbook/playbook_include.py", 
line 43, in load
return PlaybookInclude().load_data(ds=data, basedir=basedir, 
variable_manager=variable_manager, loader=loader)
  File 
"/usr/lib/python2.7/site-packages/ansible/playbook/playbook_include.py", 
line 58, in load_data
new_obj = super(PlaybookInclude, self).load_data(ds, variable_manager, 
loader)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/base.py", line 245
, in load_data
ds = self.preprocess_data(ds)
  File 
"/usr/lib/python2.7/site-packages/ansible/playbook/playbook_include.py", 
line 118, in preprocess_data
self._preprocess_import(ds, new_ds, k, v)
  File 
"/usr/lib/python2.7/site-packages/ansible/playbook/playbook_include.py", 
line 141, in _preprocess_import
items = split_args(v)
  File "/usr/lib/python2.7/site-packages/ansible/parsing/splitter.py", line 
161, in split_args
args = args.strip()
AttributeError: 'AnsibleSequence' object has no attribute 'strip'


-- 
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/6512971a-d505-40ca-b431-75c508923762%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] letsencrypt module - account_key

2018-02-13 Thread Michael Bubb
Hello -

I am a little confused by what is needed in the account_key parameter.

The docs say it is:

*File containing the Let's Encrypt account RSA key.*
*Can be created with openssl rsa *
I know when I first setup the account it generated keys in 
/etc/letsencrypt/accounts/...

They are in a json format though:

https://github.com/certbot/certbot/blob/master/tests/letstest/testdata/sample-config/accounts/acme-staging.api.letsencrypt.org/directory/48d6b9e8d767eccf7e4d877d6ffa81e3/private_key.json

I didnt think they needed to be created - perhaps an openssl export?

what is that parameter looking for?


thanks


Michael

-- 
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/50da5791-c316-4fed-be34-04e4d37061fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Looping over nested inventory items with conditional

2018-02-13 Thread flowerysong
On Tuesday, February 13, 2018 at 4:02:57 PM UTC-5, Jason Gilfoil wrote:
>
>
> We're migrating from a single load balancer pair for all systems 
> (dev/test/qa/prod) to separate pairs for dev/test and qa/prod. As a result, 
> my previous task to pull nodes from the pool on the load balancer will no 
> longer suffice without some conditional logic. I have a partial solution, 
> but it two issues. 
>
> 1st Issue
> In the following code i'm attempting to make it so that if the server is 
> in the test inventory group, it uses the dev-test f5 pair and if it's not, 
> use the qa-prod f5 pair. The first issue is that it loops over all 
> combinations so the task would essentially execute twice for each f5 
> target. 
>
> https://pastebin.com/ZxkPqvPF
>
> 2nd Issue
> The second problem is that i need to expand the conditional to allow 
> multiple statements. 
>
> I need to find a way to expand this line:
>   msg: "{{ (inventory_hostname in groups['test']) | 
> ternary(hostvars[item[0]].ansible_host,hostvars[item[1]].ansible_host) }}"
> into
>   msg: "{{ (inventory_hostname in groups['test'] OR inventory_hostname 
> in groups['dev']) | 
> ternary(hostvars[item[0]].ansible_host,hostvars[item[1]].ansible_host) }}"
>

 I'm not entirely sure of your constraints, but it seems like you would 
want something more 
like https://gist.github.com/flowerysong/ae18f75d2103b41198149380e8d6fb1c 
rather than a nested loop.

-- 
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/de494e3c-e47c-4ea9-ab1a-1586eefda4a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] jinja help

2018-02-13 Thread Kai Stian Olstad
On Tuesday, 13 February 2018 20.01.05 CET John Harmon wrote:
> Is there a good place to find out what I can/can't do for this kind of 
> stuff (maybe even just a cheat sheet)?  I don't know anything about jinja 
> and don't know the best place to start.  Also, how would you change the 
> above to exclude "sql-db" when in the ansible_hostname fact?

The Jinja template documentation is always a good start/read
http://jinja.pocoo.org/docs/2.10/templates/

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


[ansible-project] Looping over nested inventory items with conditional

2018-02-13 Thread Jason Gilfoil
Hey all, 

We're migrating from a single load balancer pair for all systems 
(dev/test/qa/prod) to separate pairs for dev/test and qa/prod. As a result, 
my previous task to pull nodes from the pool on the load balancer will no 
longer suffice without some conditional logic. I have a partial solution, 
but it two issues. 

1st Issue
In the following code i'm attempting to make it so that if the server is in 
the test inventory group, it uses the dev-test f5 pair and if it's not, use 
the qa-prod f5 pair. The first issue is that it loops over all combinations 
so the task would essentially execute twice for each f5 target. 

https://pastebin.com/ZxkPqvPF

2nd Issue
The second problem is that i need to expand the conditional to allow 
multiple statements. 

I need to find a way to expand this line:
  msg: "{{ (inventory_hostname in groups['test']) | 
ternary(hostvars[item[0]].ansible_host,hostvars[item[1]].ansible_host) }}"
into
  msg: "{{ (inventory_hostname in groups['test'] OR inventory_hostname 
in groups['dev']) | 
ternary(hostvars[item[0]].ansible_host,hostvars[item[1]].ansible_host) }}"

which doesn't work currently. 

I'm wondering if there's a way to salvage this method or if i need another 
approach entirely. I've considered just hard coding the f5's into a 
group_variable, but i'd like to avoid that and leverage the inventory 
instead if possible.

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/9b246b44-2479-4a83-a6a3-75205ab3e571%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: How to get processeur vendor ?

2018-02-13 Thread Eric Secrist
Hi Flow,
Did you ever get an answer to your question. I see a different number of 
list values for ansible_processor between two hosts, which makes it 
difficult to easily gather the processor vendor across many hosts.

ok: [host1] => {

"hostvars[inventory_hostname].ansible_processor": [

"GenuineIntel",

"Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz",

"GenuineIntel",

"Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz"

]

}

ok: [host2] => {

"hostvars[inventory_hostname].ansible_processor": [

"0",

"GenuineIntel",

"Intel(R) Xeon(R) CPU E5-2680 0 @ 2.70GHz",

"1",

"GenuineIntel",

"Intel(R) Xeon(R) CPU E5-2680 0 @ 2.70GHz"

]

}

host2 has the extra list values of "0" and "1".

Thanks,
Eric

On Friday, January 12, 2018 at 8:50:38 AM UTC-7, Florent wrote:
>
> Hi, 
>
> I would like to get the processor vendor of any host. 
>
> I see a lot of examples over the internet using a condition like this : 
>
> '"Intel" in ansible_processor[0]' 
>
> But my "ansible_processor[0]" variable on my hosts contains ... "0" !! 
>
> I use Ansible 2.4.2.0. When did it change ? Is it expected to work like 
> this ? What about computers having single CPU ? 
>
> Thank you. 
>
> Flo 
>
>

-- 
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/5adbb41d-8f41-43ec-999d-b95aa5dc2cba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: jinja help

2018-02-13 Thread John Harmon
Thanks Jason.  I also found that this works too:
when: not(ansible_hostname | lower | search ("sql-db"))



On Tuesday, February 13, 2018 at 1:25:37 PM UTC-7, Jason Gilfoil wrote:
>
> Not sure about your second question, but as for your first, this should 
> work.
>
> when: ansible_hostname | lower | search ("sql-db") == False
>
> No idea where I found it originally, i just dug through my own scripts for 
> an example.
>
> On Tuesday, February 13, 2018 at 2:01:05 PM UTC-5, John Harmon wrote:
>>
>> I need to take this and do the opposite:
>> when: ansible_hostname | lower | search ("sql-db")
>>
>> ie: when: not(ansible_hostname | lower | search ("ebs-db"))
>>
>> Is there a good place to find out what I can/can't do for this kind of 
>> stuff (maybe even just a cheat sheet)?  I don't know anything about jinja 
>> and don't know the best place to start.  Also, how would you change the 
>> above to exclude "sql-db" when in the ansible_hostname fact?
>>
>>

-- 
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/47bdd3f3-6e95-4094-b7dc-e3fcdffa215b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: jinja help

2018-02-13 Thread Jason Gilfoil
Not sure about your second question, but as for your first, this should 
work.

when: ansible_hostname | lower | search ("sql-db") == False

No idea where I found it originally, i just dug through my own scripts for 
an example.

On Tuesday, February 13, 2018 at 2:01:05 PM UTC-5, John Harmon wrote:
>
> I need to take this and do the opposite:
> when: ansible_hostname | lower | search ("sql-db")
>
> ie: when: not(ansible_hostname | lower | search ("ebs-db"))
>
> Is there a good place to find out what I can/can't do for this kind of 
> stuff (maybe even just a cheat sheet)?  I don't know anything about jinja 
> and don't know the best place to start.  Also, how would you change the 
> above to exclude "sql-db" when in the ansible_hostname fact?
>
>

-- 
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/3e7c06af-df7a-4449-a42b-a758c8362c78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Connecting to Windows hosts in EC2 using Kerberos (Tower) (maybe not what you think)

2018-02-13 Thread travisk
Hello!

Currently in Tower we have dynamic inventory set up to pull in data about 
EC2 instances from our AWS account. We have vpc_destination_variable set to 
internal IPs since we connect to EC2 via Direct Connect.

After a lot of work, I have Kerberos working with my Windows hosts! 
However, my current issue is that this only works when the target is a 
hostname that exists in AD, not an IP address.

By convention, all of our EC2 instances have their Name tag set to match 
the AD hostname of the instance. So what I would like to do is setup my 
dynamic EC2 inventory to use the Name tag's value as the host's target 
value instead of the internal IP. Unfortunately, I have the impression that 
this is not possible, since the vpc_destination_variable must be one of the 
boto.ec2.instance variables specified 
here 
http://docs.pythonboto.org/en/latest/ref/ec2.html#module-boto.ec2.instance, 
which does not include tags as an option.

But maybe I'm looking at this the wrong way - is there a straightforward 
way to achieve what I'm trying to do? A dynamic inventory that will use 
Windows/AD host names as the target, at least? Ideally by using the built 
in utilities that pull from EC2? Any thoughts on how to approach this 
problem appreciated.

Thank you,

Travis



-- 
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/ee2d73e4-735a-4d48-a8aa-57be0c293abd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Using 2 inventories. Can someone explain what I'm doing wrong?

2018-02-13 Thread Varun Chopra
Thanks. I read your post and realized what I did wrong.

/workspace was my working directory and workstation's my hostname. Mixed up 
the two. :l

On Tuesday, February 13, 2018 at 11:08:42 PM UTC+5:30, Vyacheslav wrote:
>
>
> >  Missing (or not readable) key file: '/workstation/gcloud/
> credentials.json'
>
> what says ls -la /workstation/gcloud | grep credentials.json ?
>
>>

-- 
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/042e44cf-b1f9-4574-90eb-5881e6cac3ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] jinja help

2018-02-13 Thread John Harmon
I need to take this and do the opposite:
when: ansible_hostname | lower | search ("sql-db")

ie: when: not(ansible_hostname | lower | search ("ebs-db"))

Is there a good place to find out what I can/can't do for this kind of 
stuff (maybe even just a cheat sheet)?  I don't know anything about jinja 
and don't know the best place to start.  Also, how would you change the 
above to exclude "sql-db" when in the ansible_hostname fact?

-- 
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/01984ddb-5e50-445d-8c0b-c5836feb7246%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] library/module_utils functionality question

2018-02-13 Thread Arthur Reyes
Follow-up. I tested copying a module from core into the playbook library. 
Modifying the content, without altering the module name and observed that 
ansible.library picked up the local module first.

-- 
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/bf35e3a0-ce5f-497e-af77-21bd60acfd91%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: Using 2 inventories. Can someone explain what I'm doing wrong?

2018-02-13 Thread Vyacheslav

>  Missing (or not readable) key file: '/workstation/gcloud/
credentials.json'

what says ls -la /workstation/gcloud | grep credentials.json ?

On Tuesday, 13 February 2018 17:06:35 UTC+1, Varun Chopra wrote:
>
> So I plan to use a static and a dynamic inventory (gce) and this is what 
> my play folder looks like:
>
> .
> ├── ansible.cfg
> ├── credentials.json
> ├── gce_vars
> │   ├── auth
> │   └── test_servers
> ├── group_vars
> │   └── all
> ├── hosts.yml
> ├── inventory
> │   ├── gce.ini
> │   ├── gce.py
> │   └── hosts.yml
> └── provision.yml
>
> 3 directories, 10 files
>
>
> credentials.json is the json private key for my service account.
>
> [root@workstation gcloud]# cat gce_vars/auth
> ---
> service_account_email: "x-...@developer.gserviceaccount.com 
> "
> path_to_credentials: /workspace/gcloud/credentials.json
> project_id: "heroic-XXX-XXX"
> ...
>
> gce.ini
>
> [gce]
> libcloud_secrets =
> gce_service_account_email_address = X-compute@developer.
> gserviceaccount.com
> gce_service_account_pem_file_path = /workstation/gcloud/credentials.json
> gce_project_id = heroic-XXX-XXX
>
> [inventory]
> inventory_ip_type = external
>
> [cache]
> cache_path = ~/.ansible/tmp
> cache_max_age = 300
>
> However, when I try to run the dynamic inventory, I get this error:
>
> [root@workstation inventory]# ./gce.py --list
> Traceback (most recent call last):
>   File "./gce.py", line 508, in 
> GceInventory()
>   File "./gce.py", line 170, in __init__
> self.driver = self.get_gce_driver()
>   File "./gce.py", line 318, in get_gce_driver
> gce = get_driver(Provider.GCE)(*args, **kwargs)
>   File "/usr/lib/python2.7/site-packages/libcloud/compute/drivers/gce.py", 
> line 1795, in __init__
> super(GCENodeDriver, self).__init__(user_id, key, **kwargs)
>   File "/usr/lib/python2.7/site-packages/libcloud/common/base.py", line 
> 975, in __init__
> self.connection = self.connectionCls(*args, **conn_kwargs)
>   File "/usr/lib/python2.7/site-packages/libcloud/compute/drivers/gce.py", 
> line 99, in __init__
> credential_file=credential_file, **kwargs)
>   File "/usr/lib/python2.7/site-packages/libcloud/common/google.py", line 
> 767, in __init__
> user_id, key, auth_type, credential_file, scopes, **kwargs)
>   File "/usr/lib/python2.7/site-packages/libcloud/common/google.py", line 
> 653, in __init__
> self.user_id, self.key, self.scopes, **kwargs)
>   File "/usr/lib/python2.7/site-packages/libcloud/common/google.py", line 
> 495, in __init__
> "file: '%s'" % key)
> ValueError: Missing (or not readable) key file: 
> '/workstation/gcloud/credentials.json'
>
>
>

-- 
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/de244804-97c6-48a1-a16f-0c9cacce59b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible Module Documentation

2018-02-13 Thread Brian Coca
You might just want to use ansible-doc  to verify the docs
are correct, that does not require any downloading. You only require
the full repo if you actually want an HTML version.


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


[ansible-project] Re: What's the safest way to do grep-like searches in files?

2018-02-13 Thread Arthur Reyes
Not knowing the state of your environment or what you intend to do with the 
registered fact, I can only offer you this advice:

If a line in a file needs to exist and an action should occur if that file 
is changed, line in file is the most precise way to do this operation.

If you are using searches or other methods to find values in a file in 
order to notify actions, you haven't added additional precision to your 
plays. The risk of using regular expression is no different if you use line 
in file or if you use grep. There's some great regular expression builders 
on the web. Try using that to improve the precision of lineinfile, instead 
of querying system states using grep or other utilities.

On Tuesday, February 13, 2018 at 10:53:52 AM UTC-6, Nico Sabbi wrote:
>
>
> That may turn out to be too late depending on the complexity of the R.E.
> It's not an error-proof approach.
>
> Il giorno martedì 13 febbraio 2018 16:48:53 UTC, Arthur Reyes ha scritto:
>>
>> You should run your playbook in check mode until you're certain that your 
>> regular expression is precise.
>>
>> On Tuesday, February 13, 2018 at 10:45:57 AM UTC-6, Nico Sabbi wrote:
>>>
>>> HI,
>>> I need to do a grep-like search in a file without using shell commands 
>>> and in a check_mode compatible way.
>>> I just need to check  the presence of a given string a in a file without 
>>> doing overwrites of any kind.
>>> I implemented something with lineinfile but I'm very annoyed by the need 
>>> to  specify the line parameter to overwrite the file
>>> because the r.e. may be wrong.
>>>
>>> Is there any cleaner way to do what I need?
>>>
>>> - name: grub
>>>   become: true
>>>   lineinfile:
>>> path: /etc/myfile
>>> backrefs: yes 
>>> regexp: "^CMDLINE (.*)"
>>> line: 'CMDLINE \1'
>>> state: present
>>>   register: myxx
>>>
>>>
>>> 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/f2911815-cb99-49e5-9af8-702d6e0fe6bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: What's the safest way to do grep-like searches in files?

2018-02-13 Thread Brian Coca
The find module has a 'contains' option.




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


[ansible-project] Re: What's the safest way to do grep-like searches in files?

2018-02-13 Thread Nico Sabbi

That may turn out to be too late depending on the complexity of the R.E.
It's not an error-proof approach.

Il giorno martedì 13 febbraio 2018 16:48:53 UTC, Arthur Reyes ha scritto:
>
> You should run your playbook in check mode until you're certain that your 
> regular expression is precise.
>
> On Tuesday, February 13, 2018 at 10:45:57 AM UTC-6, Nico Sabbi wrote:
>>
>> HI,
>> I need to do a grep-like search in a file without using shell commands 
>> and in a check_mode compatible way.
>> I just need to check  the presence of a given string a in a file without 
>> doing overwrites of any kind.
>> I implemented something with lineinfile but I'm very annoyed by the need 
>> to  specify the line parameter to overwrite the file
>> because the r.e. may be wrong.
>>
>> Is there any cleaner way to do what I need?
>>
>> - name: grub
>>   become: true
>>   lineinfile:
>> path: /etc/myfile
>> backrefs: yes 
>> regexp: "^CMDLINE (.*)"
>> line: 'CMDLINE \1'
>> state: present
>>   register: myxx
>>
>>
>> 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/4dd755fe-ec09-4fe0-b404-e68cdcbb30eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] What's the safest way to do grep-like searches in files?

2018-02-13 Thread Nico Sabbi

I like it. Thanks

Il giorno martedì 13 febbraio 2018 16:50:44 UTC, Matt Martz ha scritto:
>
> I would honestly use slurp to fetch the file and maybe a set_fact to set a 
> var indicating it's existence.  That is the pattern I have always used.  
> Something like:
>
> - slurp:
> path: /etc/myfile
>   register: myfile
>
> - set_fact:
> contains_cmdline: "{{ myfile.contents|b64decode|search("^CMDLINE") }}"
>
> On Tue, Feb 13, 2018 at 10:45 AM, Nico Sabbi  > wrote:
>
>> HI,
>> I need to do a grep-like search in a file without using shell commands 
>> and in a check_mode compatible way.
>> I just need to check  the presence of a given string a in a file without 
>> doing overwrites of any kind.
>> I implemented something with lineinfile but I'm very annoyed by the need 
>> to  specify the line parameter to overwrite the file
>> because the r.e. may be wrong.
>>
>> Is there any cleaner way to do what I need?
>>
>> - name: grub
>>   become: true
>>   lineinfile:
>> path: /etc/myfile
>> backrefs: yes 
>> regexp: "^CMDLINE (.*)"
>> line: 'CMDLINE \1'
>> state: present
>>   register: myxx
>>
>>
>> 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-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/0ca75bd8-67b9-43f3-87cb-0dbdeacd0088%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/a70b50d5-fa9b-48cb-9903-b9e58722aba4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] What's the safest way to do grep-like searches in files?

2018-02-13 Thread Matt Martz
I would honestly use slurp to fetch the file and maybe a set_fact to set a
var indicating it's existence.  That is the pattern I have always used.
Something like:

- slurp:
path: /etc/myfile
  register: myfile

- set_fact:
contains_cmdline: "{{ myfile.contents|b64decode|search("^CMDLINE") }}"

On Tue, Feb 13, 2018 at 10:45 AM, Nico Sabbi  wrote:

> HI,
> I need to do a grep-like search in a file without using shell commands and
> in a check_mode compatible way.
> I just need to check  the presence of a given string a in a file without
> doing overwrites of any kind.
> I implemented something with lineinfile but I'm very annoyed by the need
> to  specify the line parameter to overwrite the file
> because the r.e. may be wrong.
>
> Is there any cleaner way to do what I need?
>
> - name: grub
>   become: true
>   lineinfile:
> path: /etc/myfile
> backrefs: yes
> regexp: "^CMDLINE (.*)"
> line: 'CMDLINE \1'
> state: present
>   register: myxx
>
>
> 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/0ca75bd8-67b9-43f3-87cb-0dbdeacd0088%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-uvL_YoQxKaX5X_OZXUT2rS4YFPpO%2BW2_CcwJ81VoisQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: What's the safest way to do grep-like searches in files?

2018-02-13 Thread Arthur Reyes
You should run your playbook in check mode until you're certain that your 
regular expression is precise.

On Tuesday, February 13, 2018 at 10:45:57 AM UTC-6, Nico Sabbi wrote:
>
> HI,
> I need to do a grep-like search in a file without using shell commands and 
> in a check_mode compatible way.
> I just need to check  the presence of a given string a in a file without 
> doing overwrites of any kind.
> I implemented something with lineinfile but I'm very annoyed by the need 
> to  specify the line parameter to overwrite the file
> because the r.e. may be wrong.
>
> Is there any cleaner way to do what I need?
>
> - name: grub
>   become: true
>   lineinfile:
> path: /etc/myfile
> backrefs: yes 
> regexp: "^CMDLINE (.*)"
> line: 'CMDLINE \1'
> state: present
>   register: myxx
>
>
> 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/5d8a82c8-cf6a-46b4-8010-61e4dc8be05a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] What's the safest way to do grep-like searches in files?

2018-02-13 Thread Nico Sabbi
HI,
I need to do a grep-like search in a file without using shell commands and 
in a check_mode compatible way.
I just need to check  the presence of a given string a in a file without 
doing overwrites of any kind.
I implemented something with lineinfile but I'm very annoyed by the need 
to  specify the line parameter to overwrite the file
because the r.e. may be wrong.

Is there any cleaner way to do what I need?

- name: grub
  become: true
  lineinfile:
path: /etc/myfile
backrefs: yes 
regexp: "^CMDLINE (.*)"
line: 'CMDLINE \1'
state: present
  register: myxx


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/0ca75bd8-67b9-43f3-87cb-0dbdeacd0088%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] library/module_utils functionality question

2018-02-13 Thread Arthur Reyes
If a module with the same name as a core module exists in the ./library or 
./module_utils directory of the plabyook, which module will be get invoked 
when I reference it in my playbook?

I have a need to modify the functionality of a core module. I could 
refactor/rename it to [module]_internal or simply copy the module to 
./library and add the needed functionality, so I'm curious how others have 
approached this. I see benefits of creating a new (renamed) module with the 
added functionality and refactoring my playbook to invoke this module 
instead, but there's other benefits to just slipping the modified module 
directly into the ./library directory so that no further changes are 
required in the playbook.

Thoughts?

-- 
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/dc48af50-c7a2-4913-8514-7d72f0b2848e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Using 2 inventories. Can someone explain what I'm doing wrong?

2018-02-13 Thread Varun Chopra
So I plan to use a static and a dynamic inventory (gce) and this is what my 
play folder looks like:

.
├── ansible.cfg
├── credentials.json
├── gce_vars
│   ├── auth
│   └── test_servers
├── group_vars
│   └── all
├── hosts.yml
├── inventory
│   ├── gce.ini
│   ├── gce.py
│   └── hosts.yml
└── provision.yml

3 directories, 10 files


credentials.json is the json private key for my service account.

[root@workstation gcloud]# cat gce_vars/auth
---
service_account_email: "x-comp...@developer.gserviceaccount.com"
path_to_credentials: /workspace/gcloud/credentials.json
project_id: "heroic-XXX-XXX"
...

gce.ini

[gce]
libcloud_secrets =
gce_service_account_email_address = X-compute@developer.gserviceaccount.
com
gce_service_account_pem_file_path = /workstation/gcloud/credentials.json
gce_project_id = heroic-XXX-XXX

[inventory]
inventory_ip_type = external

[cache]
cache_path = ~/.ansible/tmp
cache_max_age = 300

However, when I try to run the dynamic inventory, I get this error:

[root@workstation inventory]# ./gce.py --list
Traceback (most recent call last):
  File "./gce.py", line 508, in 
GceInventory()
  File "./gce.py", line 170, in __init__
self.driver = self.get_gce_driver()
  File "./gce.py", line 318, in get_gce_driver
gce = get_driver(Provider.GCE)(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/libcloud/compute/drivers/gce.py", 
line 1795, in __init__
super(GCENodeDriver, self).__init__(user_id, key, **kwargs)
  File "/usr/lib/python2.7/site-packages/libcloud/common/base.py", line 
975, in __init__
self.connection = self.connectionCls(*args, **conn_kwargs)
  File "/usr/lib/python2.7/site-packages/libcloud/compute/drivers/gce.py", 
line 99, in __init__
credential_file=credential_file, **kwargs)
  File "/usr/lib/python2.7/site-packages/libcloud/common/google.py", line 
767, in __init__
user_id, key, auth_type, credential_file, scopes, **kwargs)
  File "/usr/lib/python2.7/site-packages/libcloud/common/google.py", line 
653, in __init__
self.user_id, self.key, self.scopes, **kwargs)
  File "/usr/lib/python2.7/site-packages/libcloud/common/google.py", line 
495, in __init__
"file: '%s'" % key)
ValueError: Missing (or not readable) key file: 
'/workstation/gcloud/credentials.json'


-- 
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/2c046b46-4dc0-46d3-bbd4-b999b27db76d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] In a loop everything executes at the same time?

2018-02-13 Thread Guillem Sola
Very interesting, so then each host individually needs 0 sec for the 
iterations it doesn't execute which ends up with all the hosts executing 
the tasks at the same time.

I was inspired by this 
comment https://github.com/ansible/ansible/issues/12170#issuecomment-283950548 
but now I understand it is not possible then.

Thanks



https://github.com/ansible/ansible/issues/12170#issuecomment-283950548

On Monday, February 12, 2018 at 11:31:19 PM UTC+1, Brian Coca wrote:
>
> kind of, the result is similar to what you expected but not the same, 
> a loop gets 'unrolled' into N tasks (1 per item) per host, but they 
> are grouped as a single task per host for the results. 
>
> The loop itself is sequential (within the same host) but in parallel 
> with the same task/loop with other hosts. 
>
>
>
>
> -- 
> -- 
> 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/73c62bf2-3203-4714-bc63-8174fa5a8695%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Yaml statement over multiple lines.

2018-02-13 Thread Kai Stian Olstad
On Tuesday, 13 February 2018 13.25.24 CET mail.philfri...@gmail.com wrote:
> How should I split this dest: statement into multiple lines ?
> 
> - copy:
> content: "{{ config.stdout[0] }}"
> *dest: "{{ backup_root }}/{{ inventory_hostname }}/dhcp_leases_{{ 
> ansible_date_time.year }}{{ ansible_date_time.month }}{{ 
> ansible_date_time.day }}{{ ansible_date_time.hour }}{{ 
> ansible_date_time.minute }}{{ ansible_date_time.second }}"*

You can try this

  - copy:
  content: "{{ config.stdout[0] }}"
  dest: "{{ backup_root }}/\
{{ inventory_hostname }}/\
dhcp_leases_{{ ansible_date_time.year }}\
{{ ansible_date_time.month }}\
{{ ansible_date_time.day }}\
{{ ansible_date_time.hour }}\
{{ ansible_date_time.minute }}\
{{ ansible_date_time.second }}"


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


[ansible-project] Yaml statement over multiple lines.

2018-02-13 Thread mail . philfriend
Hi,

How should I split this dest: statement into multiple lines ?

- copy:
content: "{{ config.stdout[0] }}"
*dest: "{{ backup_root }}/{{ inventory_hostname }}/dhcp_leases_{{ 
ansible_date_time.year }}{{ ansible_date_time.month }}{{ 
ansible_date_time.day }}{{ ansible_date_time.hour }}{{ 
ansible_date_time.minute }}{{ ansible_date_time.second }}"*


Thanks in advance,

Phil.

-- 
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/5ef51658-223d-48c0-9ad8-1e9bc7d12730%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Dictionary Parsing

2018-02-13 Thread Mona Gopal


We are trying to write Ansible playbooks for releasing patches for an 
application

In patch releases there are 4 basic changes that can be there 

We will create 4 roles for those

BinaryRole : For changing war files and jar files with backup and replacing 
the existing configurations

ConfigRole: For adding / deleting / modifying parameters from the 
configuration files with backup 

DBRole : For changes related to DB . SQL source file will be used 

NonCompile: For replacing static files like JSPs or Resource_Properties

 

While working on the ConfigRole I am using the dictionary variables for 
defining files and parameters will require change in those files

The parameters can be either added or modified or removed from the config 
file

Below is the dictionary variable that I have defined and the corresponding 
task that I have used that variable in

 

*Inside group_vars file*

 

configFiles:


/home/BM/apache-tomcat-8.0.35/webapps/OBDReport/WEB-INF/classes/COMMON.properties:

   paramName: DB_USER

   paramValue: dbansible

   change: 3

 

*Inside playbook in ConfigRole*

 

- name: change configurations modified

  lineinfile: dest={{ item.key }} regexp='^{{ item.value.paramName }}=' 
line={{ item.value.paramName }}={{ item.value.paramValue }}

  when: "{{ item.value.change }}|int==3"

  with_dict: "{{ configFiles | default({}) }}"

 

- name: change configurations added

  lineinfile: dest={{ item.key }} line={{ item.value.paramName }}={{ 
item.value.paramValue }}

  when: "{{ item.value.change }}|int==2"

  with_dict: "{{ configFiles | default({}) }}"

 

In the above task based on the change value parameters will be modified for 
value 3 and added for value 2

While looping over the dictionary configFiles:   ansible is able to read 
only one value of every key 

Here key is 
/home/BM/apache-tomcat-8.0.35/webapps/OBDReport/WEB-INF/classes/COMMON.properties
 
and value is the set of values (paramName , paramValue, change )

If there are multiple parameters in the same file which require change then 
how do we define those in the group_vars file and how to loop through the 
same in the task file in the role

 

If I write the vars as below

configFiles:


/home/BM/apache-tomcat-8.0.35/webapps/OBDReport/WEB-INF/classes/COMMON.properties:

   paramName: DB_USER

   paramValue: dbansible

   change: 3

   paramName: DB_USER_1

   paramValue: dbansible1

   change: 2

Then it will only read the last set of values for each key.

Please help in resolving this or suggest if we can use some other approach


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/9b0e4896-bea1-4adb-aafe-099614f13390%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Dynamic Inventory using Active Directory / LDAP

2018-02-13 Thread Michael Ströder
aa...@klep.net wrote:
> Does anyone have code that can pull a dynamic inventory from list of AD
> OUs?  Want to use the windows_update module to patch our servers only in
> specific OUs.
> 
> Maybe I missed it, but I don't see Windows Active Directory inventory
> here:  https://github.com/ansible/ansible/tree/devel/contrib/inventory

I've never used it myself but you could try to tweak this one to match
your specific needs:

https://github.com/vincentvdk/ansible_inventory/tree/master/ldap

Ciao, Michael.

-- 
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/85d5a457-4bbd-b80e-4f1b-1423c46feb70%40stroeder.com.
For more options, visit https://groups.google.com/d/optout.


smime.p7s
Description: S/MIME Cryptographic Signature