[ansible-project] merge two sets of AWS tags?

2018-05-20 Thread Karl Auer
I am clearly having a brain failure, but I can't figure out how to merge 
two sets of AWS tags.

AWS tags are generally defined as a variable (or attribute in a module) 
something like this:

tags:
   name1: value1
   name2: value2

So I will generally have some standard tags set up in a variable like this:

standard_tags:
   Name: AServer
   CostCentre: Operations

Then I generate some extra tags, so I have another variable somewhere like 
this:

extra_tags:
   fred: wilma
   barney: betty

How can I get one variable that looks like this:

all_tags:
   Name: AServer
   CostCentre: Operations
   fred: wilma
   barney: betty

?

Regards, K.

-- 
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/feaf5ae3-0e26-43bc-8e87-7998bc1a55e2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Ansible GUI Tools

2018-05-20 Thread Carlton Patterson
Hello community,

I am learning Ansible and I am getting familiar with Ansible's commands.

However, can someone let me know if there are any GUI applications that 
will allow the building of Playbooks and inventories etc?

I have been using an application called PlayAble which is a great tool 
developed by an Ansible expert called Mumshad, see the following link for a 
demo http://www.ansible-playable.com/

Its a great tool, but I was wondering if there are any other tools on the 
market?

Cheers

Carlton

-- 
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/7e4379de-b20a-4ec0-b8e4-7b2b4229b140%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Abridged summary of ansible-project@googlegroups.com - 14 updates in 5 topics

2018-05-20 Thread Kannappan M
Hi  Team,

Am  trying to run the shutdown command in my ansible master server using
the below  command

[tester@ansi ~]$ sudo ansible Total -m shell  -a "/usr/sbin/shutdown -h now"

got  the  error  message  as

server 1 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Permission denied
(publickey,gssapi-keyex,gssapi-with-mic,password).\r\n",
"unreachable": true


but  when i  use  the

ansible Total -a "/bin/date"

am  able  to  get  the result  kindly  assit






Regards
Kannappan M
+91-9894921536


On Sun, May 20, 2018 at 10:13 PM,  wrote:

> ansible-project@googlegroups.com
> 
>  Google
> Groups
> 
> 
> Today's topic summary
> View all topics
> 
>
>- Check if all the values of a yml matches a string else throw error
>and exit in ansible <#m_-8274689085338957318_group_thread_0> - 7
>Updates
>- Decrypting/Encrypting Ansible Vault on Windows
><#m_-8274689085338957318_group_thread_1> - 1 Update
>- Ansible Command Module Argument Entry
><#m_-8274689085338957318_group_thread_2> - 4 Updates
>- How to Use Ansible to Determine differing features of a Machine
><#m_-8274689085338957318_group_thread_3> - 1 Update
>- Passing variable value from one role to the next using Ansible for
>AWS <#m_-8274689085338957318_group_thread_4> - 1 Update
>
> Check if all the values of a yml matches a string else throw error and
> exit in ansible
> 
> BIJAY PARIDA : May 19 10:48PM -0700
>
> Hi,
>
>
> I have two files file1.yml and file2.yml which I am passing from the
> deployment level.
>
> I want to verify that all the values of the file1 matches to a string else
> exits with error ...more
> 
> Kai Stian Olstad : May 20 10:28AM +0200
>
> On 20.05.2018 07:48, BIJAY PARIDA wrote:
>
> > Both value1 and value2 are different and I want to check the respective
> > files and their values.
>
> > And assert the condition file1.values | uniqe == ...more
> 
> BIJAY PARIDA : May 20 02:30AM -0700
>
> Thanks a lot Kai for the response. Here I don't want to include the vars,
> just want to check if the file exists and it contains the string.
>
> Is there any alternate? I meant without using the ...more
> 
> BIJAY PARIDA : May 20 03:12AM -0700
>
> The length comparison works well.
>
> But when comparing the string it fails.
>
> - assert:
>
> # that: "file1values | unique | length == 1"
> that: file1values.get('values') | ...more
> 
> Kai Stian Olstad : May 20 12:20PM +0200
>
> On 20.05.2018 11:30, BIJAY PARIDA wrote:
> > vars,
> > just want to check if the file exists and it contains the string.
>
> > Is there any alternate? I meant without using the include_vars option.
> ...more
> 
> Kai Stian Olstad : May 20 12:29PM +0200
>
> On 20.05.2018 12:12, BIJAY PARIDA wrote:
> > that: file1values.get('values') | unique == 'drop' - Tried
> > with
> > get values.
>
> file1values is a list so the get method wont work. ...more
> 
> BIJAY PARIDA : May 20 03:34AM -0700
>
> Thanks a lot for the help, I will take it forward from here to add some
> more conditional checks.
>
> --
> Bijay
>
> On Sunday, 20 May 2018 15:59:26 UTC+5:30, Kai Stian Olstad wrote:
> ...more
> 
> Back to top <#m_-8274689085338957318_digest_top>
> Decrypting/Encrypting Ansible Vault on Windows
> 
> Jordan Borean : May 19 11:10PM -0700
>
> Hey
>
> This is a shameless self post but recently I've been spending some time
> trying to understand how Ansible Vault works and I decided to apply what I
> learnt by creating some PowerShell cmdlets ...more
> 

Re: [ansible-project] Intended behavior of variable expansion in role handlers?

2018-05-20 Thread Kai Stian Olstad

On 16.05.2018 19:28, luciano.cavalhe...@gmail.com wrote:

roles/some_role/defaults.yml:
instance_name: "default"
instance_conf_file: "/etc/servicename-{{instance_name}}.conf"
instance_param1: "some value"
instance_param2: "some other value"

roles/some_role/tasks.yml:
- template:
dest: {{instance_conf_file}}
src: some_role_conf.j2
  notify:
- reload conf

roles/some_role/handers.yml:
- name: reload conf
  command: some command to reload  {{instance_name}} 
{{instance_conf_file}}


In the main playbook, I call the role multiple times with different 
values

for instance parameters, like this:

- hosts: all
  roles:
# first instance "default"
- role: some_role

# second instance
- role: some_role
  instance_name: "i2"
  instance_param1: "abc"

   # third instance
- role: some_role
  instance_name: "i3"
  instance_param1: "xyz"

When configuration of either "i2" or 'i3" is modified, notification to
"reload conf" actually goes to handler of first instance (variables in
"reload conf" are filled with default values).

I would expect that, like for tasks, variables in role/handlers.yml 
were

evaluated considering the current role environment.


Handlers only run once no mater how many times they are notified and 
handlers run is triggered after all the roles is finished.




Should I open a bug or this is the intended behavior? If this is the
intended behavior, are there any other means to pass instance 
parameters to

handlers?


Since handlers is special passing parameters to it is not trivial.

You could instead have "register: result" on the template instead of 
notify and just have command as a regular task with this added "when: 
result is changed"


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


Re: [ansible-project] Check if all the values of a yml matches a string else throw error and exit in ansible

2018-05-20 Thread BIJAY PARIDA
Thanks a lot for the help, I will take it forward from here to add some 
more conditional checks.

--
Bijay

On Sunday, 20 May 2018 15:59:26 UTC+5:30, Kai Stian Olstad wrote:
>
> On 20.05.2018 12:12, BIJAY PARIDA wrote: 
> > The length comparison works well. 
> > 
> > But when comparing the string it fails. 
> > 
> >  - assert: 
> > 
> > # that: "file1values | unique | length == 1" 
> >  that: file1values.get('values') | unique == 'drop'  - Tried 
> > with 
> > get values. 
>
> file1values is a list so the get method wont work. 
> unique return a list of unique values of a list, ["a", "a", "b"] becomes 
> ["a", "b"] and ["a", "a", "a"] becomes ["a"] so you can't compare that 
> to a string. 
>
>
> -- 
> 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/1b6bb497-329d-405c-9084-6d1ca4665c83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Check if all the values of a yml matches a string else throw error and exit in ansible

2018-05-20 Thread Kai Stian Olstad

On 20.05.2018 11:30, BIJAY PARIDA wrote:
Thanks a lot Kai for the response. Here I don't want to include the 
vars,

just want to check if the file exists and it contains the string.

Is there any alternate? I meant without using the include_vars option.


You can always use shell

  - shell: cut -f2 -d":" /path/to/file1.yml | uniq | wc -l
register: r

  - assert:
  that: r.stdout == "1"

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


Re: [ansible-project] Check if all the values of a yml matches a string else throw error and exit in ansible

2018-05-20 Thread BIJAY PARIDA
The length comparison works well.

But when comparing the string it fails.

 - assert:

# that: "file1values | unique | length == 1"
 that: file1values.get('values') | unique == 'drop'  - Tried with 
get values.


--
Bijay


On Sunday, 20 May 2018 15:00:51 UTC+5:30, BIJAY PARIDA wrote:
>
> Thanks a lot Kai for the response. Here I don't want to include the vars, 
> just want to check if the file exists and it contains the string.
>
> Is there any alternate? I meant without using the include_vars option.
>
> --
> Bijay
>
>
> On Sunday, 20 May 2018 13:58:31 UTC+5:30, Kai Stian Olstad wrote:
>>
>> On 20.05.2018 07:48, BIJAY PARIDA wrote: 
>> > I have two files file1.yml and file2.yml which I am passing from the 
>> > deployment level. 
>> > 
>> > I want to verify that all the values of the file1 matches to a string 
>> > else 
>> > exits with error message, same with the 2nd file. 
>> > 
>> > 
>> > file1.yml (value field is same) 
>> > === 
>> > 
>> > "item1" : "value" 
>> > "item2" : "value" 
>> > "item3" : "value" 
>> > 
>> > 
>> > file2.yml (value2 field is same) 
>> > === 
>> > 
>> > "item1" : "value2" 
>> > "item2" : "value2" 
>> > "item3" : "value2" 
>> > 
>> > Both value1 and value2 are different and I want to check the respective 
>> > files and their values. 
>> > 
>> > And assert the condition file1.values | uniqe == value1 
>>
>> Not pretty but it should get the job done. 
>>
>>- include_vars: 
>>file: file1.yml 
>>name: file1 
>>
>>- set_fact: 
>>file1values: "{{ file1values | default([]) + [item.1] }}" 
>>  with_items: 
>>- "{{ file1 | dictsort }}" 
>>
>>- assert: 
>>  that: file1values | unique | length == 1 
>>
>> -- 
>> 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/2ed7bc77-0349-49cc-b4d3-aac678ccb6d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Check if all the values of a yml matches a string else throw error and exit in ansible

2018-05-20 Thread BIJAY PARIDA
Thanks a lot Kai for the response. Here I don't want to include the vars, 
just want to check if the file exists and it contains the string.

Is there any alternate? I meant without using the include_vars option.

--
Bijay


On Sunday, 20 May 2018 13:58:31 UTC+5:30, Kai Stian Olstad wrote:
>
> On 20.05.2018 07:48, BIJAY PARIDA wrote: 
> > I have two files file1.yml and file2.yml which I am passing from the 
> > deployment level. 
> > 
> > I want to verify that all the values of the file1 matches to a string 
> > else 
> > exits with error message, same with the 2nd file. 
> > 
> > 
> > file1.yml (value field is same) 
> > === 
> > 
> > "item1" : "value" 
> > "item2" : "value" 
> > "item3" : "value" 
> > 
> > 
> > file2.yml (value2 field is same) 
> > === 
> > 
> > "item1" : "value2" 
> > "item2" : "value2" 
> > "item3" : "value2" 
> > 
> > Both value1 and value2 are different and I want to check the respective 
> > files and their values. 
> > 
> > And assert the condition file1.values | uniqe == value1 
>
> Not pretty but it should get the job done. 
>
>- include_vars: 
>file: file1.yml 
>name: file1 
>
>- set_fact: 
>file1values: "{{ file1values | default([]) + [item.1] }}" 
>  with_items: 
>- "{{ file1 | dictsort }}" 
>
>- assert: 
>  that: file1values | unique | length == 1 
>
> -- 
> 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/ae3d1203-0473-4c6b-ba2f-31f33ddee646%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Check if all the values of a yml matches a string else throw error and exit in ansible

2018-05-20 Thread Kai Stian Olstad

On 20.05.2018 07:48, BIJAY PARIDA wrote:

I have two files file1.yml and file2.yml which I am passing from the
deployment level.

I want to verify that all the values of the file1 matches to a string 
else

exits with error message, same with the 2nd file.


file1.yml (value field is same)
===

"item1" : "value"
"item2" : "value"
"item3" : "value"


file2.yml (value2 field is same)
===

"item1" : "value2"
"item2" : "value2"
"item3" : "value2"

Both value1 and value2 are different and I want to check the respective
files and their values.

And assert the condition file1.values | uniqe == value1


Not pretty but it should get the job done.

  - include_vars:
  file: file1.yml
  name: file1

  - set_fact:
  file1values: "{{ file1values | default([]) + [item.1] }}"
with_items:
  - "{{ file1 | dictsort }}"

  - assert:
that: file1values | unique | length == 1

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


[ansible-project] Decrypting/Encrypting Ansible Vault on Windows

2018-05-20 Thread Jordan Borean
Hey

This is a shameless self post but recently I've been spending some time 
trying to understand how Ansible Vault works and I decided to apply what I 
learnt by creating some PowerShell cmdlets to encrypt/decrypt a vault file 
in Windows. If you are one of the poor unfortunate souls who are forced to 
develop on Windows, especially if you can't use Windows 10/WSL, I hope this 
is of some use to you.

The code is located here 
https://github.com/jborean93/PowerShell-AnsibleVault and I've also written 
a post about the whole process here 
https://www.bloggingforlogging.com/2018/05/20/decrypting-the-secrets-of-ansible-vault-in-powershell/.
 
To install the cmdlets just run `Install-Module -Name AnsibleVault` (you 
need PS v5 or PowerShellGet installed), otherwise you can copy them across 
manually.

Thanks

Jordan

-- 
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/1101cfe0-4507-4c9d-b2ef-b18825f5da46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.