[ansible-project] Re: ansible error 'first argument must be string or compiled pattern'

2019-08-27 Thread Fae Az
found the solution. i should use '#\s+Hostname\=' in quotes

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/087116eb-6479-4a03-9aed-c3d697585bef%40googlegroups.com.


[ansible-project] Cannot use the pexpect module with Keybase pgp and multiple ':' characters

2019-08-27 Thread Andrew Graham


I'm wondering why the pexpect module is failing in this 
circumstance, perhaps my regex is not right, but the double ':' may be 
messing with things as well and I'm not sure how to approach handling it.


if I run-


keybase pgp encrypt -m 'secret' | keybase pgp decrypt


Then this prompt may occur, which I cant seem to catch.


Please enter your Keybase passphrase to unlock the secret key for:
PGP key andrew_graham  KJ2G34K4J3H1K234J 

Reason: PGP Decryption:



here is an example of my attempts with expect:


- name: Case insensitive password string match
expect:
chdir: /vagrant
command: '/bin/bash -c "echo {{ secret }} | base64 --decode | keybase pgp 
decrypt"'
responses:
.*Please enter your Keybase passphrase to unlock the secret key for \[.*\]: "{{ 
keybase_secret }}"
.*Please enter your Keybase passphrase to unlock the secret key for.*: "{{ 
keybase_secret }}"
^Reason\[:.*\] PGP Decryption\[:.*\]: "{{ keybase_secret }}"

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e6a5f169-ef38-4fe2-8198-7f4274dbc416%40googlegroups.com.


Re: [ansible-project] list seen as unicode, not sure why or how to correct

2019-08-27 Thread Nicholas Britton
That provides me this:

TASK [debug number on array after unuiqe] 
***
ok: [localhost] => {
"msg": "'\"10\"'"
}


how do i clean that up to only get the value 10 out of it? 

The end result i am expecting is for the list to look like:

'10','11','15'


On Tuesday, August 27, 2019 at 3:51:35 PM UTC-5, Kai Stian Olstad wrote:
>
> On 27.08.2019 22:32, Nicholas Britton wrote: 
> > And this error when the next uri call attempts to use it, notice, how at 
> > the end i puts the list in unicode format, and the url does not know how 
> to 
> > interpret that. 
> > TASK [list sessions for 886000428027 - ams] 
> > 
> *
>  
>
> > fatal: [localhost]: FAILED! => {"changed": false, "connection": "close", 
> > "content": " > 2.0//EN\">\n\n400 Bad 
> > Request\n\nBad Request\nYour browser 
> sent 
> > a request that this server could not understand. > />\n\n\n", "content_length": "226", "content_type": 
> "text/html; 
> > charset=iso-8859-1", "date": "Tue, 27 Aug 2019 20:26:28 GMT", "elapsed": 
> 0, 
> > "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", 
> > "redirected": false, "server": "Apache", "status": 400, "url": "
> https://ip/ConfigurationManager/v1/views/lun-paths?$query=ldev.storageDeviceId%20eq%20'886000428027'%20and%20hostGroup.hostGroupNumber%20in%20'[u'10',
>  
>
> > u'11', u'12', u'13', u'14', u'15', u'16', u'9']'"} 
>
> You can use the to_json filter to get "clean" json output. 
>
>
> -- 
> 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/923d0d66-8060-4f3e-b43c-b3f009bcb235%40googlegroups.com.


Re: [ansible-project] Ansible Windows Custom Modules

2019-08-27 Thread Jordan Borean

>
> 1. Is it allowed (as per the GNU license) to also customize the existing 
> Windows Modules or only add new ones?
>

Please note I am not an IP lawyer so I recommend you talk to your company's 
legal team if you actually want legal advice.

Of course, any community member can make changes to the modules through a 
PR. You cannot change the license for certain bits of code but if you want 
to fix a bug, add a new feature, or something else, you can raise a PR 
right now.

2. When using the module win_lineinfile on a file that contains information 
> we could use to check if a user is logged in to a specific application we 
> get an access denied. The important point is that the application only 
> writes changes to the file when a user logs in or logs out, it has an 
> active handle on the file in-between but doesn't write any information. 
> Would "become" help with this?
>

Probably not, if a thread has an open handle to a file and does not allow 
other reads or writes then there's nothing you can do. Each handle is per 
thread and not per logon session so even the same user in the same logon 
session wouldn't be able to open a new handle to that file. This all 
happens quite deep within Windows and the file is "locked" until that 
handle is closed, or you change the code that opens the handle to allow 
more sharing options.

3. The Windows Module in github that are present as python version, are 
> they only a documentation stub or do they server another purpose? When 
> writing custom Windows modules, is it sufficient to have them written in 
> PowerShell or is there any benefit in having a Python version, too?
>

Yep, we have a .py equivalent file for each Windows module and it's purely 
for documentation purposes. We parse these files and generate our online 
docs so that's why we have kept them the same. Right now if you want to 
write a module for Windows it needs to be in PowerShell. You cannot run 
Python modules on Windows, or at least use a Python module with our shared 
utils on Windows.

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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2ae403a2-4d5f-4d9d-be96-cd5681ec953b%40googlegroups.com.


Re: [ansible-project] list seen as unicode, not sure why or how to correct

2019-08-27 Thread Kai Stian Olstad
On 27.08.2019 22:32, Nicholas Britton wrote:
> And this error when the next uri call attempts to use it, notice, how at
> the end i puts the list in unicode format, and the url does not know how to
> interpret that.
> TASK [list sessions for 886000428027 - ams]
> *
> fatal: [localhost]: FAILED! => {"changed": false, "connection": "close",
> "content": " 2.0//EN\">\n\n400 Bad
> Request\n\nBad Request\nYour browser sent
> a request that this server could not understand. />\n\n\n", "content_length": "226", "content_type": 
> "text/html;
> charset=iso-8859-1", "date": "Tue, 27 Aug 2019 20:26:28 GMT", "elapsed": 0,
> "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request",
> "redirected": false, "server": "Apache", "status": 400, "url": 
> "https://ip/ConfigurationManager/v1/views/lun-paths?$query=ldev.storageDeviceId%20eq%20'886000428027'%20and%20hostGroup.hostGroupNumber%20in%20'[u'10',
> u'11', u'12', u'13', u'14', u'15', u'16', u'9']'"}

You can use the to_json filter to get "clean" json output.


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e628c5b2-7db9-1ab6-5d38-98689549d77e%40olstad.com.


Re: [ansible-project] Can I run plays in parallel?

2019-08-27 Thread Jonathan Lozada De La Matta
Right. Just mentioning an option.

On Tue, Aug 27, 2019 at 4:37 PM Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On 27.08.2019 22:33, Jonathan Lozada De La Matta wrote:
> > you can run multiple plays in one playbook. For example:
> >
> > hosts: localhost
> > roles:
> >- create_vm
> >
> > hosts: vm_created
> > roles:
> >- configure_vm
> >
> > this also assumes you are using add_host in the first play.
>
> Nick is asking for play in parallel, this will still be serial.
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/e374f21a-c854-706b-8bd4-a6f030da9609%40olstad.com
> .
>


-- 

Jonathan Cha'gara Lozada De La Matta

He / Him / His

Red Hat 

Senior Automation Practice Consultant & Automation CoP Manager

Join the Automation CoP! https://red.ht/autocop
@redhatjobs    redhatjobs
 @redhatjobs



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAFYJA%2BLzwJOQzWuA00AGqrp7rGZTub_tk0ggXvuHyrBiLEHy9g%40mail.gmail.com.


Re: [ansible-project] Can I run plays in parallel?

2019-08-27 Thread Kai Stian Olstad
On 27.08.2019 22:33, Jonathan Lozada De La Matta wrote:
> you can run multiple plays in one playbook. For example:
> 
> hosts: localhost
> roles:
>- create_vm
> 
> hosts: vm_created
> roles:
>- configure_vm
> 
> this also assumes you are using add_host in the first play.

Nick is asking for play in parallel, this will still be serial.


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e374f21a-c854-706b-8bd4-a6f030da9609%40olstad.com.


Re: [ansible-project] Can I run plays in parallel?

2019-08-27 Thread Jonathan Lozada De La Matta
you can run multiple plays in one playbook. For example:

hosts: localhost
roles:
  - create_vm

hosts: vm_created
roles:
  - configure_vm

this also assumes you are using add_host in the first play.

On Tue, Aug 27, 2019 at 4:26 PM Kai Stian Olstad <
ansible-project+l...@olstad.com> wrote:

> On 27.08.2019 22:21, Nick Kakouros wrote:
> > Is there a way to say to ansible to run all plays in parallel? I could
> find
> > workaround in bash, but I would like to know if this is possible in
> ansible.
>
> It's not possible in Ansible, so you would need to run multiple
> ansible-playbook in bash.
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/e1c11175-13f9-0f47-d74c-71744a9e36a6%40olstad.com
> .
>


-- 

Jonathan Cha'gara Lozada De La Matta

He / Him / His

Red Hat 

Senior Automation Practice Consultant & Automation CoP Manager

Join the Automation CoP! https://red.ht/autocop
@redhatjobs    redhatjobs
 @redhatjobs



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAFYJA%2B%2B7h-WQpEOmYL6-%3DvGmc3t9Rj95hANbnbCGYTM-8YQc1w%40mail.gmail.com.


[ansible-project] list seen as unicode, not sure why or how to correct

2019-08-27 Thread Nicholas Britton
I am building a list with output stored from a uri call:

  - name: Get hostgroup info
uri:
  url: 
"{{baseurl}}views/host-groups?$query=hostGroup.storageDeviceId%20eq%20'{{ui}}'%20and%20hostGroup.hostGroupName%20in%20[{{vmc02}}]"
  method: get
  validate_certs: no
  headers:
Authorization: "Session {{login.json.token}}"
Accept: "application/json"
Content-Type: "application/json"
register: hostgroups


 - name: create list of hostgroups ids
set_fact:
  hostgroupnum_l: "{{hostgroupnum_l}} + 
['{{item.hostGroup.hostGroupNumber}}']"
with_items: "{{hostgroups.json.data}}"



But when the data is debuged it gives me this difference if i look at one 
item or multiple:


TASK [debug hostgroup list object] 
**
ok: [localhost] => {
"msg": [
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"9"
]
}


TASK [debug hostgroupnumber output] 
*
ok: [localhost] => {
"msg": "u'10'"
}


And this error when the next uri call attempts to use it, notice, how at 
the end i puts the list in unicode format, and the url does not know how to 
interpret that.
TASK [list sessions for 886000428027 - ams] 
*
fatal: [localhost]: FAILED! => {"changed": false, "connection": "close", 
"content": "\n\n400 Bad 
Request\n\nBad Request\nYour browser sent 
a request that this server could not understand.\n\n\n", "content_length": "226", "content_type": 
"text/html; 
charset=iso-8859-1", "date": "Tue, 27 Aug 2019 20:26:28 GMT", "elapsed": 0, 
"msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", 
"redirected": false, "server": "Apache", "status": 400, "url": 
"https://ip/ConfigurationManager/v1/views/lun-paths?$query=ldev.storageDeviceId%20eq%20'886000428027'%20and%20hostGroup.hostGroupNumber%20in%20'[u'10',
 
u'11', u'12', u'13', u'14', u'15', u'16', u'9']'"}




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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/68cd892f-628b-43a5-8477-63c13c979b1c%40googlegroups.com.


Re: [ansible-project] Can I run plays in parallel?

2019-08-27 Thread Kai Stian Olstad
On 27.08.2019 22:21, Nick Kakouros wrote:
> Is there a way to say to ansible to run all plays in parallel? I could find
> workaround in bash, but I would like to know if this is possible in ansible.

It's not possible in Ansible, so you would need to run multiple 
ansible-playbook in bash.


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e1c11175-13f9-0f47-d74c-71744a9e36a6%40olstad.com.


[ansible-project] Re: Best practice: Ansible default filename extension for its files

2019-08-27 Thread Gilson Soares [GM]
Thanks Kai for your thoughts.

On Tuesday, August 27, 2019 at 3:17:56 PM UTC-3, Gilson Soares [GM] wrote:
>
> I'm new using Ansible but I'd like to start using best practices.
>
> I know that Ansible uses YAML syntax files, not "Ansible format".
> Looking thru the docs, there are several documents using interchangeably  
> YML and YAML.
>
> For example: using ansible_playbook ,  *must* include the 
> extension.
> What about some editors which colorizing the syntax.
> Which extension it expects to have to properly identify the file ?
>
> Does anyone have a tip about it ?
>
>
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/553ea3e3-2834-4c2d-ad2c-def73368fc4d%40googlegroups.com.


[ansible-project] Can I run plays in parallel?

2019-08-27 Thread Nick Kakouros
I have 10 files with a play each. In total these plays provision 4 hosts. I 
have written a function in bash that takes as an argument the host I want 
to provision and calls ansible with all 10 playbooks and a `-l`(limit) 
parameter for only the host I provided. I can pass multiple hosts too.

So, when I pass 3 hosts, ansible starts running and it goes through each 
play one by one. This means that a host may have to unnecessarily wait for 
previous plays to finish before it is the turn of one of its play. 

Is there a way to say to ansible to run all plays in parallel? I could find 
workaround in bash, but I would like to know if this is possible in ansible.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/46931a49-feab-42db-8ed4-eaad4464b221%40googlegroups.com.


Re: [ansible-project] Registering value from JSON output

2019-08-27 Thread Vladimir Botka
On Tue, 27 Aug 2019 12:44:15 -0700 (PDT)
Cade Lambert  wrote:

> [...]
> "output": {
>  "json": {
>   "results": [
> {
>  "name": "item1"
>  "id": "26"
>  }
> {
>  "name": "item2"
>  "id": "29"
>  }
> {
>  "name": "item3"
>  "id": "10"
>  }
>  ]
>}
> }
> 
> What I'd like to do is place the id into a variable only when the name 
> matches a string.
> 
> I was trying something like this but it fails because the variable is a 
> list.
> 
>   - set_fact:
>   host_id: "{{ item.id }}"
> when: item.name == "item2"
> loop: "{{ results_var.output.json.results }}"

json_query does the job. For example

- set_fact:
host_id: "{{ json.results|json_query('[?name==`item2`].id') }}"

if the data is properly structured.

  json:
results:
- id: '26'
  name: item1
- id: '29'
  name: item2
- id: '10'
  name: item3

Cheers,

-vlado

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20190827220550.3b5cc24b%40gmail.com.


pgpN6mjEwy0f8.pgp
Description: OpenPGP digital signature


Re: [ansible-project] Support for installing Ansible on Windows

2019-08-27 Thread Jordan Borean
No plans, it will work but in the odd case it doesn’t you won’t get any help 
from GitHub unless you ca replicate it on an actual Linux platform.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6ead9f91-903a-4e4c-ae4b-b6822b31c217%40googlegroups.com.


Re: [ansible-project] Registering value from JSON output

2019-08-27 Thread Kai Stian Olstad
On 27.08.2019 21:44, Cade Lambert wrote:
> I'm trying to register the value of a JSON object only when another JSON
> object is equal to a certain value, but I just can't figure out how I'd do
> that.
> 
> For example, this is my JSON output which is registered in the variable
> results_var:
> 
> "output": {
>   "json": {
>"results": [
>  {
>   "name": "item1"
>   "id": "26"
>   }
>  {
>   "name": "item2"
>   "id": "29"
>   }
>  {
>   "name": "item3"
>   "id": "10"
>   }
>   ]
> }
> }

This output looks wired, it's missing commas after } in the list.


> What I'd like to do is place the id into a variable only when the name
> matches a string.
> 
> I was trying something like this but it fails because the variable is a
> list.
> 
>- set_fact:
>host_id: "{{ item.id }}"
>  when: item.name == "item2"
>  loop: "{{ results_var.output.json.results }}"

You should always provide the exact error message and probably the all the code 
too, at fist glance I don't see anything wrong with the code.


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2d1b222c-a02c-f436-a15f-3c822bb30f1a%40olstad.com.


[ansible-project] Re: Search for string in stdout for failed_when

2019-08-27 Thread JP-OKC
Thanks Kai,   That worked.

On Tuesday, August 27, 2019 at 2:10:20 PM UTC-5, JP-OKC wrote:
>
> how can I pull a string from the stdout and use it for failed_when?I 
> run a command on a switch and then I want to match a string w/in that 
> output to determine if it failed or not.
>
> Here's what the playbook looks like:
>
> ---
> - name: Check the ssh keypair on a Nexus 9k
>   hosts: all
>   gather_facts: false
>   connection: network_cli
>   tasks:
>   - block:
> - name: show keypair
>   nxos_command:
> commands: "show username someuser keypair"
>   ignore_unreachable: true
>   register: print_output
>   failed_when: ("could not retrieve rsa key information" in 
> print_output.stdout)
>   - debug: var=print_output
>
>
>
>
>
> Here's what the debug output looks like.I want to match on the 3rd 
> line of the stdout_lines.
>
> ok: [switchB] => {
> "print_output": {
> "ansible_facts": {
> "discovered_interpreter_python": "/usr/bin/python"
> },
> "changed": false,
> "failed": false,
> "failed_when_result": false,
> "stdout": [
> "**\n\ncould not retrieve 
> rsa key information\n**\n\ncould not 
> retrieve dsa key 
> information\n**\n\ncould not retrieve 
> ecdsa key information\n**"
> ],
> "stdout_lines": [
> [
> "**",
> "",
> "could not retrieve rsa key information",
> "**",
> "",
> "could not retrieve dsa key information",
> "**",
> "",
> "could not retrieve ecdsa key information",
> "**"
> ]
> ]
> }
> }
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/fbabcdf4-bef2-4372-8bd4-2b389c5d4bcb%40googlegroups.com.


[ansible-project] Registering value from JSON output

2019-08-27 Thread Cade Lambert
I'm trying to register the value of a JSON object only when another JSON 
object is equal to a certain value, but I just can't figure out how I'd do 
that.

For example, this is my JSON output which is registered in the variable 
results_var:

"output": {
 "json": {
  "results": [
{
 "name": "item1"
 "id": "26"
 }
{
 "name": "item2"
 "id": "29"
 }
{
 "name": "item3"
 "id": "10"
 }
 ]
   }
}

What I'd like to do is place the id into a variable only when the name 
matches a string.

I was trying something like this but it fails because the variable is a 
list.

  - set_fact:
  host_id: "{{ item.id }}"
when: item.name == "item2"
loop: "{{ results_var.output.json.results }}"


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a2c3746a-47a3-4e9f-b6fe-510e8841fe6e%40googlegroups.com.


Re: [ansible-project] Support for installing Ansible on Windows

2019-08-27 Thread 'John Thompson' via Ansible Project
Thanks for the reply Jonathan. Much appreciated.

Is there an official answer out there publicly, or someone who can confirm
in the product group?

J

On Mon, Aug 26, 2019, 13:57 Jonathan Lozada De La Matta 
wrote:

> someone else can answer  officially but, as far as I know there is no plan
> to support installing ansible on windows.
>
> On Mon, Aug 26, 2019 at 2:39 PM 'John Thompson' via Ansible Project <
> ansible-project@googlegroups.com> wrote:
>
>> Hi,
>>
>> I have done some searching but can't see if there is any update on
>> supporting the installation of Ansible on Windows? I'd be interested to
>> know if there are any plans?
>>
>>
>> https://docs.ansible.com/ansible/latest/user_guide/windows_faq.html#can-ansible-run-on-windows
>>
>> Also, as the FAQ gives the only option as WSL, but states this isn't
>> supported by Ansible are there plans to support WSL at least in the future?
>>
>> Thanks.
>>
>> John
>>
>>
>>
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/fb89d020-77fd-4571-9d13-d7919e4b8cf5%40googlegroups.com
>> 
>> .
>>
>
>
> --
>
> Jonathan Cha'gara Lozada De La Matta
>
> He / Him / His
>
> Red Hat 
>
> Senior Automation Practice Consultant & Automation CoP Manager
>
> Join the Automation CoP! https://red.ht/autocop
> @redhatjobs    redhatjobs
>  @redhatjobs
> 
> 
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAFYJA%2B%2B--yJfxjPRHCBdyJhfH7eVVZEaU9D3RGs%2BU24236WC9Q%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAKVKOB6CZ7Qw-QP6sqrTXua2pX4GVSf1jc4ufx4gMLLfueznvA%40mail.gmail.com.


Re: [ansible-project] Search for string in stdout for failed_when

2019-08-27 Thread Kai Stian Olstad
On 27.08.2019 21:10, JP-OKC wrote:
> how can I pull a string from the stdout and use it for failed_when?I
> run a command on a switch and then I want to match a string w/in that
> output to determine if it failed or not.
> 
> Here's what the playbook looks like:
> 
> ---
> - name: Check the ssh keypair on a Nexus 9k
>hosts: all
>gather_facts: false
>connection: network_cli
>tasks:
>- block:
>  - name: show keypair
>nxos_command:
>  commands: "show username someuser keypair"
>ignore_unreachable: true
>register: print_output
>failed_when: ("could not retrieve rsa key information" in
> print_output.stdout)
>- debug: var=print_output
> 
> 
> 
> 
> 
> Here's what the debug output looks like.I want to match on the 3rd line
> of the stdout_lines.
> 
> ok: [switchB] => {
>  "print_output": {
>  "ansible_facts": {
>  "discovered_interpreter_python": "/usr/bin/python"
>  },
>  "changed": false,
>  "failed": false,
>  "failed_when_result": false,
>  "stdout": [

As you can see here the [ indicate a list so first element is 0.
The nxos_command takes several commands, the first command is in list element 
0, the second one is list element 1 and so on

so you need to use element 0 like this

failed_when: ("could not retrieve rsa key information" in print_output.stdout.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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2192b02c-03f3-92ee-9f18-8ac65f342adf%40olstad.com.


[ansible-project] Search for string in stdout for failed_when

2019-08-27 Thread JP-OKC
how can I pull a string from the stdout and use it for failed_when?I 
run a command on a switch and then I want to match a string w/in that 
output to determine if it failed or not.

Here's what the playbook looks like:

---
- name: Check the ssh keypair on a Nexus 9k
  hosts: all
  gather_facts: false
  connection: network_cli
  tasks:
  - block:
- name: show keypair
  nxos_command:
commands: "show username someuser keypair"
  ignore_unreachable: true
  register: print_output
  failed_when: ("could not retrieve rsa key information" in 
print_output.stdout)
  - debug: var=print_output





Here's what the debug output looks like.I want to match on the 3rd line 
of the stdout_lines.

ok: [switchB] => {
"print_output": {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"failed": false,
"failed_when_result": false,
"stdout": [
"**\n\ncould not retrieve 
rsa key information\n**\n\ncould not 
retrieve dsa key 
information\n**\n\ncould not retrieve 
ecdsa key information\n**"
],
"stdout_lines": [
[
"**",
"",
"could not retrieve rsa key information",
"**",
"",
"could not retrieve dsa key information",
"**",
"",
"could not retrieve ecdsa key information",
"**"
]
]
}
}

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/407fe665-42a8-4264-9c77-e40099cdb525%40googlegroups.com.


Re: [ansible-project] Best practice: Ansible default filename extension for its files

2019-08-27 Thread Kai Stian Olstad
On 27.08.2019 20:17, Gilson Soares [GM] wrote:
> I'm new using Ansible but I'd like to start using best practices.

IMHO it's no best practice to fit all, it all comes down to what's best for you.


> I know that Ansible uses YAML syntax files, not "Ansible format".

Well, that's not entirely correct, Ansible has two type of syntax YAML and key 
value.
Recommendation is to use YAML, but I use them both because key value is faster 
to write for short debug tasks.

This key value is faster to write
- debug: var=myvar

than this YAML
- debug:
var: myvar


> Looking thru the docs, there are several documents using interchangeably
> YML and YAML.
> 
> For example: using ansible_playbook ,  *must* include the
> extension.

Most if not all Linux/Unix programs and that includes Ansible don't care about 
the file extension.
So you can call them whatever you like, officially I think the YAML people 
recommend .yaml as the extension.


> What about some editors which colorizing the syntax.
> Which extension it expects to have to properly identify the file ?

It depends on you editor I guess.

I'm using vim with this plugin[1] and configure it for .yml files that I use 
for Ansible, and for clean YAML files, aka not Ansible files, get the default 
vim YAML syntax setting.


[1] https://github.com/pearofducks/ansible-vim


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/cdeb12c6-5b2d-a67a-0596-3b821a63f4a2%40olstad.com.


[ansible-project] Best practice: Ansible default filename extension for its files

2019-08-27 Thread Gilson Soares [GM]
I'm new using Ansible but I'd like to start using best practices.

I know that Ansible uses YAML syntax files, not "Ansible format".
Looking thru the docs, there are several documents using interchangeably  
YML and YAML.

For example: using ansible_playbook ,  *must* include the 
extension.
What about some editors which colorizing the syntax.
Which extension it expects to have to properly identify the file ?

Does anyone have a tip about it ?



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/e6a15867-6703-4b96-9ace-188c8f367bd1%40googlegroups.com.


[ansible-project] Re: Rolling out latest Virtualbox via ansible?

2019-08-27 Thread Knut Karevoll
What you are looking for is the set_fact module. This allows you to set a 
variable in the current context which will allow you to use it in the 
subsequent tasks in the play.

On Tuesday, August 27, 2019 at 3:42:28 PM UTC+2, scorp123 wrote:
>
> I want to roll out the latest Virtualbox onto my Ubuntu 18.04 servers via 
> ansible. What I've managed so far is an installer-script that gets copied 
> over to any host in the "virtualbox" hosts group (as per ansible hosts 
> configuration file), then gets remotely executed and does this job. While 
> this solution "gets the job done" it's more of a "quick and dirty hack" and 
> not really elegant. What's the proper way to do this via pure ansible 
> playbook code? E.g. I would like to write playbook code that determines the 
> latest version of Virtualbox and then installs it, just like the bash 
> script below does. Is there any way to do this? So my playbook so far looks 
> like this: ``` --- - hosts: virtualbox tasks: - name: Copy the repo file if 
> needed copy: src: 
> /home/admin/System_Configs/sources.list.d/18.04/virtualbox.list dest: 
> /etc/apt/sources.list.d/ mode: 0644 owner: root group: root - name: Make 
> sure repo keys are installed if needed apt_key: url: "
> https://www.virtualbox.org/download/{{ item }}.asc" state: present 
> with_items: - oracle_vbox - oracle_vbox_2016 - name: Transfer the installer 
> script copy: src: /home/admin/System_Configs/bin/virtualbox-installer.sh 
> dest: /tmp/ mode: 0755 owner: root group: root - name: Execute the 
> installer script shell: /tmp/virtualbox-installer.sh changed_when: False 
> register: scriptoutput - debug: var={{ item }} with_items: - 
> scriptoutput.stdout_lines ``` ... and the script that is called looks like 
> this: ``` #! /bin/bash cd /tmp rm /tmp/*.vbox-extpack >/dev/null 2>&1 wget 
> -q -N https://download.virtualbox.org/virtualbox/LATEST-STABLE.TXT 
> VBOXVERSION=`cat /tmp/LATEST-STABLE.TXT` echo "Latest Virtualbox is: 
> "$VBOXVERSION MAJORVERSION=`cat /tmp/LATEST-STABLE.TXT | cut -d. -f1,2` 
> echo "Latest major release is: "$MAJORVERSION apt install 
> virtualbox-$MAJORVERSION INSTALLEDVBOXVERSION=`VBoxManage --version | sed 
> -r 's/([0-9])\.([0-9])\.([0-9]{1,2}).*/\1.\2.\3/'` echo "Installed 
> Virtualbox is: "$INSTALLEDVBOXVERSION echo wget -q -N "
> http://download.virtualbox.org/virtualbox/$INSTALLEDVBOXVERSION/Oracle_VM_VirtualBox_Extension_Pack-$INSTALLEDVBOXVERSION.vbox-extpack;
>  
> echo y | VBoxManage extpack install --replace 
> /tmp/Oracle_VM_VirtualBox_Extension_Pack-"$INSTALLEDVBOXVERSION".vbox-extpack 
> | grep Success rm /tmp/*.vbox-extpack >/dev/null 2>&1 rm 
> /tmp/LATEST-STABLE.TXT >/dev/null 2>&1 ``` While the script "gets the job 
> done" ... meh. I'd like a proper ansible playbook that could do this. All 
> the examples on Ansible Galaxy that I've looked at needed the Virtualbox 
> version number statically defined as variable inside their playbooks or 
> their role's variable definitions not really what I want. I'd like to 
> get ansible to look at the "LATEST-STABLE.TXT" file on Oracle's web site, 
> read that into a variable, and then act accordingly. So my ansible playbook 
> would need to: * read the contents of "
> https://download.virtualbox.org/virtualbox/LATEST-STABLE.TXT; * assign 
> that resulting number to a variable ("6.0.10") * cut that number down so we 
> know the major release ("6.0") * install the "virtualbox-*" package that 
> results from that ("virtualbox-6.0") * download and install the Extension 
> Package too ("Oracle_VM_VirtualBox_Extension_Pack-6.0.10.vbox-extpack") 
> I've been tinkering around with "get_url", "slurp", "fetch", "lookup" and 
> what not but I always fail to get the content of "LATEST-STABLE.TXT" 
> assigned to a variable. What would be a proper Ansible way to do that? 
> Thanks in advance for any help <3 
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/646cca38-4f30-4b4c-9722-85fc917130ea%40googlegroups.com.


Re: [ansible-project] when: ansible conditional's based on distribution major version

2019-08-27 Thread Jeffrey Agnitsch
That worked thank you very much!

On Tuesday, August 27, 2019 at 10:29:28 AM UTC-5, Michael M wrote:
>
> Jeffrey, 
>
> Try: 
>
> when: ansible_distribution_major_version == '7' 
>
> On Tue, Aug 27, 2019 at 8:07 AM Jeffrey Agnitsch 
> > wrote: 
> > 
> > I am trying to copy over .rpm files based on the major version of the 
> operating system I believe I am referencing the ansible_facts part 
> incorrectly does anyone have an example of the right way? 
> > 
> > tasks: 
> > - name: Copy kernel RHEL6 
> >   copy: 
> > src: 
> /etc/ansible/files/individual_files/test/kernel-2.6.32-754.15.3.el6.x86_64.rpm
>  
>
> > dest: /tmp/kernel-2.6.32-754.15.3.el6.x86_64.rpm 
> > owner: root 
> > group: root 
> > mode: 0644 
> >   when: ansible_facts['distribution_major_version'] == '6' 
> > 
> > - name: Copy kernel RHEL6 firmware 
> >   copy: 
> > src: 
> /etc/ansible/files/individual_files/test/kernel-firmware-2.6.32-754.15.3.el6.noarch.rpm
>  
>
> > dest: /tmp/kernel-firmware-2.6.32-754.15.3.el6.noarch.rpm 
> > owner: root 
> > group: root 
> > mode: 0644 
> >   when: ansible_facts['ansible_distribution_major_version'] == '6' 
> > 
> > - name: Copy kernel RHEL7 
> >   copy: 
> > src: 
> /etc/ansible/files/individual_files/rhel7/kernel-3.10.0-1062.el7.x86_64.rpm 
> > dest: /tmp/kernel-3.10.0-1062.el7.x86_64.rpm 
> > owner: root 
> > group: root 
> > mode: 0644 
> >   when: ansible_facts['ansible_distribution_major_version'] == '7' 
> > 
> > - name: Copy kernel RHEL7 firmware 
> >   copy: 
> > src: 
> /etc/ansible/files/individual_files/rhel7/linux-firmware-20190429-72.gitddde598.el7.noarch.rpm
>  
>
> > dest: /tmp/linux-firmware-20190429-72.gitddde598.el7.noarch.rpm 
> > owner: root 
> > group: root 
> > mode: 0644 
> >   when: ansible_facts['ansible_distribution_major_version'] == '7' 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/bb31e45d-8967-4256-821c-8c45ab6184f7%40googlegroups.com.
>  
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/53bc3b66-e15b-4042-838d-187a28f2df46%40googlegroups.com.


Re: [ansible-project] Adding a Fact to a dict for Cisco Interf.

2019-08-27 Thread Vladimir Botka
> - set_fact:
> cisco_ios: "{{ cisco_ios.interfaces|combine(interfaces) }}"

Errata:

 - set_fact:
 cisco_ios: "{{ cisco_ios|combine({'interfaces': interfaces}) }}"

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20190827173855.1c2d1563%40gmail.com.


pgpm5issBoP3s.pgp
Description: OpenPGP digital signature


Re: [ansible-project] when: ansible conditional's based on distribution major version

2019-08-27 Thread Michael Mullay
Jeffrey,

Try:

when: ansible_distribution_major_version == '7'

On Tue, Aug 27, 2019 at 8:07 AM Jeffrey Agnitsch
 wrote:
>
> I am trying to copy over .rpm files based on the major version of the 
> operating system I believe I am referencing the ansible_facts part 
> incorrectly does anyone have an example of the right way?
>
> tasks:
> - name: Copy kernel RHEL6
>   copy:
> src: 
> /etc/ansible/files/individual_files/test/kernel-2.6.32-754.15.3.el6.x86_64.rpm
> dest: /tmp/kernel-2.6.32-754.15.3.el6.x86_64.rpm
> owner: root
> group: root
> mode: 0644
>   when: ansible_facts['distribution_major_version'] == '6'
>
> - name: Copy kernel RHEL6 firmware
>   copy:
> src: 
> /etc/ansible/files/individual_files/test/kernel-firmware-2.6.32-754.15.3.el6.noarch.rpm
> dest: /tmp/kernel-firmware-2.6.32-754.15.3.el6.noarch.rpm
> owner: root
> group: root
> mode: 0644
>   when: ansible_facts['ansible_distribution_major_version'] == '6'
>
> - name: Copy kernel RHEL7
>   copy:
> src: 
> /etc/ansible/files/individual_files/rhel7/kernel-3.10.0-1062.el7.x86_64.rpm
> dest: /tmp/kernel-3.10.0-1062.el7.x86_64.rpm
> owner: root
> group: root
> mode: 0644
>   when: ansible_facts['ansible_distribution_major_version'] == '7'
>
> - name: Copy kernel RHEL7 firmware
>   copy:
> src: 
> /etc/ansible/files/individual_files/rhel7/linux-firmware-20190429-72.gitddde598.el7.noarch.rpm
> dest: /tmp/linux-firmware-20190429-72.gitddde598.el7.noarch.rpm
> owner: root
> group: root
> mode: 0644
>   when: ansible_facts['ansible_distribution_major_version'] == '7'
>
> --
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/bb31e45d-8967-4256-821c-8c45ab6184f7%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAH4rTPvbetq4a3%2BkTr%2BEJ02nPHZQhemby3HcH2ig-nWWidbtUg%40mail.gmail.com.


Re: [ansible-project] Adding a Fact to a dict for Cisco Interf.

2019-08-27 Thread Vladimir Botka
On Tue, 27 Aug 2019 07:44:24 -0700 (PDT)
Spiro Mitsialis  wrote:

> I have the following that is not working.  
> 
>   vars:
> cmdb: xkjsdflkjsjdl4d
> cisco_ios:
>interfaces:
>  gigabit1/0/1:
> name: Gigabit1/0/1
> status: up
>  gigabit1/0/2:
> name: Gigabit1/0/2
> status: down
> [...]
> I want to end up with
> 
> cisco_ios:
> interfaces:
>gigabit1/0/1:
>   name: Gigabit1/0/1
>   status: up
>   cmdbId: xx
>gigabit1/0/2:
>name: Gigabit1/0/2
>status: down
>cmdbId: xx

Is this probably what are you looking for?

- set_fact:
interfaces: "{{ interfaces|default({})|
combine({item.key: item.value|
combine({'cmdbId': cmdb})}) }}"
  loop: "{{ cisco_ios.interfaces|dict2items }}"
- set_fact:
cisco_ios: "{{ cisco_ios.interfaces|combine(interfaces) }}"

Cheers,

-vlado

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20190827172342.22b64016%40gmail.com.


pgpYDDl1OhuYV.pgp
Description: OpenPGP digital signature


[ansible-project] when: ansible conditional's based on distribution major version

2019-08-27 Thread Jeffrey Agnitsch
I am trying to copy over .rpm files based on the major version of the 
operating system I believe I am referencing the ansible_facts part 
incorrectly does anyone have an example of the right way?

tasks:
- name: Copy kernel RHEL6
  copy:
src: 
/etc/ansible/files/individual_files/test/kernel-2.6.32-754.15.3.el6.x86_64.rpm
dest: /tmp/kernel-2.6.32-754.15.3.el6.x86_64.rpm
owner: root
group: root
mode: 0644
  when: ansible_facts['distribution_major_version'] == '6'

- name: Copy kernel RHEL6 firmware
  copy:
src: 
/etc/ansible/files/individual_files/test/kernel-firmware-2.6.32-754.15.3.el6.noarch.rpm
dest: /tmp/kernel-firmware-2.6.32-754.15.3.el6.noarch.rpm
owner: root
group: root
mode: 0644
  when: ansible_facts['ansible_distribution_major_version'] == '6'

- name: Copy kernel RHEL7
  copy:
src: 
/etc/ansible/files/individual_files/rhel7/kernel-3.10.0-1062.el7.x86_64.rpm
dest: /tmp/kernel-3.10.0-1062.el7.x86_64.rpm
owner: root
group: root
mode: 0644
  when: ansible_facts['ansible_distribution_major_version'] == '7'

- name: Copy kernel RHEL7 firmware
  copy:
src: 
/etc/ansible/files/individual_files/rhel7/linux-firmware-20190429-72.gitddde598.el7.noarch.rpm
dest: /tmp/linux-firmware-20190429-72.gitddde598.el7.noarch.rpm
owner: root
group: root
mode: 0644
  when: ansible_facts['ansible_distribution_major_version'] == '7'

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/bb31e45d-8967-4256-821c-8c45ab6184f7%40googlegroups.com.


[ansible-project] Adding a Fact to a dict for Cisco Interf.

2019-08-27 Thread Spiro Mitsialis
I have the following that is not working.  

  vars:
cmdb: xkjsdflkjsjdl4d
cisco_ios:
   interfaces:
 gigabit1/0/1:
name: Gigabit1/0/1
status: up
 gigabit1/0/2:
name: Gigabit1/0/2
status: down
  tasks:
  - name: Test in loop
include: test_loop_fact2.yml
loop: "{{ cisco_ios.interfaces | dict2items }}"
  - debug:
 var: cisco_ios

*test_loop_fact2**.yml:*

- name: set fact
  set_fact:
 new_fact:
   interfaces:
   "{{ item.key }}":
  cmdbId: "{{ cmdb }}"

- name: merge
  set_fact:
 cisco_ios: "{{ cisco_ios|combine(new_fact,recursive=True) }}"
 cacheable: true


I want to be able to insert cmdbId under cisco_ios.interfaces.gigabit1/0/1 
and cisco_ios.interfaces.gigabit1/0/2 but I cannot figure out how to do 
this.  With the above I get:

TASK [debug] 

ok: [127.0.0.1] => {
"cisco_ios": {
"interfaces": {
"gigabit1/0/1": {
"name": "Gigabit1/0/1",
"status": "up"
},
"gigabit1/0/2": {
"name": "Gigabit1/0/2",
"status": "down"
},
"{{ item.key }}": {
"cmdbId": "xkjsdflkjsjdl4d"
}
}
}
}


I've tried removing the "{{ }}" and tried [ ] but get errors.  How do I 
reference it.
I want to end up with

cisco_ios:
interfaces:
   gigabit1/0/1:
  name: Gigabit1/0/1
  status: up
  cmdbId: xx
   gigabit1/0/2:
   name: Gigabit1/0/2
   status: down
   cmdbId: xx

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c49e522a-f81b-4b36-ac65-4dbb01f35a5e%40googlegroups.com.


[ansible-project] Rolling out latest Virtualbox via ansible?

2019-08-27 Thread scorp123
I want to roll out the latest Virtualbox onto my Ubuntu 18.04 servers via 
ansible. What I've managed so far is an installer-script that gets copied 
over to any host in the "virtualbox" hosts group (as per ansible hosts 
configuration file), then gets remotely executed and does this job. While 
this solution "gets the job done" it's more of a "quick and dirty hack" and 
not really elegant. What's the proper way to do this via pure ansible 
playbook code? E.g. I would like to write playbook code that determines the 
latest version of Virtualbox and then installs it, just like the bash 
script below does. Is there any way to do this? So my playbook so far looks 
like this: ``` --- - hosts: virtualbox tasks: - name: Copy the repo file if 
needed copy: src: 
/home/admin/System_Configs/sources.list.d/18.04/virtualbox.list dest: 
/etc/apt/sources.list.d/ mode: 0644 owner: root group: root - name: Make 
sure repo keys are installed if needed apt_key: url: 
"https://www.virtualbox.org/download/{{ item }}.asc" state: present 
with_items: - oracle_vbox - oracle_vbox_2016 - name: Transfer the installer 
script copy: src: /home/admin/System_Configs/bin/virtualbox-installer.sh 
dest: /tmp/ mode: 0755 owner: root group: root - name: Execute the 
installer script shell: /tmp/virtualbox-installer.sh changed_when: False 
register: scriptoutput - debug: var={{ item }} with_items: - 
scriptoutput.stdout_lines ``` ... and the script that is called looks like 
this: ``` #! /bin/bash cd /tmp rm /tmp/*.vbox-extpack >/dev/null 2>&1 wget 
-q -N https://download.virtualbox.org/virtualbox/LATEST-STABLE.TXT 
VBOXVERSION=`cat /tmp/LATEST-STABLE.TXT` echo "Latest Virtualbox is: 
"$VBOXVERSION MAJORVERSION=`cat /tmp/LATEST-STABLE.TXT | cut -d. -f1,2` 
echo "Latest major release is: "$MAJORVERSION apt install 
virtualbox-$MAJORVERSION INSTALLEDVBOXVERSION=`VBoxManage --version | sed 
-r 's/([0-9])\.([0-9])\.([0-9]{1,2}).*/\1.\2.\3/'` echo "Installed 
Virtualbox is: "$INSTALLEDVBOXVERSION echo wget -q -N 
"http://download.virtualbox.org/virtualbox/$INSTALLEDVBOXVERSION/Oracle_VM_VirtualBox_Extension_Pack-$INSTALLEDVBOXVERSION.vbox-extpack;
 
echo y | VBoxManage extpack install --replace 
/tmp/Oracle_VM_VirtualBox_Extension_Pack-"$INSTALLEDVBOXVERSION".vbox-extpack 
| grep Success rm /tmp/*.vbox-extpack >/dev/null 2>&1 rm 
/tmp/LATEST-STABLE.TXT >/dev/null 2>&1 ``` While the script "gets the job 
done" ... meh. I'd like a proper ansible playbook that could do this. All 
the examples on Ansible Galaxy that I've looked at needed the Virtualbox 
version number statically defined as variable inside their playbooks or 
their role's variable definitions not really what I want. I'd like to 
get ansible to look at the "LATEST-STABLE.TXT" file on Oracle's web site, 
read that into a variable, and then act accordingly. So my ansible playbook 
would need to: * read the contents of 
"https://download.virtualbox.org/virtualbox/LATEST-STABLE.TXT; * assign 
that resulting number to a variable ("6.0.10") * cut that number down so we 
know the major release ("6.0") * install the "virtualbox-*" package that 
results from that ("virtualbox-6.0") * download and install the Extension 
Package too ("Oracle_VM_VirtualBox_Extension_Pack-6.0.10.vbox-extpack") 
I've been tinkering around with "get_url", "slurp", "fetch", "lookup" and 
what not but I always fail to get the content of "LATEST-STABLE.TXT" 
assigned to a variable. What would be a proper Ansible way to do that? 
Thanks in advance for any help <3 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/96ea8dc6-9752-49ab-89b0-371fa39a1293%40googlegroups.com.


[ansible-project] inventory file for playbooks with only uri calls

2019-08-27 Thread Nicholas Britton
I am working on a set of playbooks for a hitachi storage automation.
They utilize a cmrest server, that manages the connection to each storage 
array.   So all of the tasks are ran on the localhost to the same url base, 
but there is a var in the path that indicates what storage array to run 
against.

I was looking at the inventory file as an option to set the vars for each 
storage array.   Each storage array would be a group, but since they all 
have localhost, the var overwrites because it belongs to multiple groups.

Does anyone have an idea of how i can achieve this or something similar to 
this?  


Here is an example of the inventory file i started with:

[amsterdam]
localhost


[amsterdam:vars]
ui=886000428027
hostss=esx001,esx002,esx003


[singapore]
localhost


[singapore:vars]
ui=4


[all:vars]
baseurl="https://10.123.123.123:23351/ConfigurationManager/v1/;



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/40a9c937-abb6-4e19-bf0b-648ef3b6b1c3%40googlegroups.com.


[ansible-project] Re: Ansible and Windows Project

2019-08-27 Thread Simon-Pierre Diamond
Anyone has something to say about this subject?

Is playing with Powershell and the GPO comes to the same as playing to the 
registry directly?

I need to create policies, and Powershell does not seem to be the answer, as 
not super versatile for GPOs with the cmdlet.

Anyone has more insights on this?

Thank you!

-Simon


This message has been sent on behalf of a company that is part of the Harris 
Operating Group of Constellation Software Inc. These companies are listed 
here.
If you prefer not to be contacted by Harris Operating Group please notify 
us.

This message is intended exclusively for the individual or entity to which it 
is addressed. This communication may contain information that is proprietary, 
privileged or confidential or otherwise legally exempt from disclosure. If you 
are not the named addressee, you are not authorized to read, print, retain, 
copy or disseminate this message or any part of it. If you have received this 
message in error, please notify the sender immediately by e-mail and delete all 
copies of the message.


From: Simon-Pierre Diamond 
Sent: August 23, 2019 2:44 PM
To: ansible-project@googlegroups.com 
Subject: Re: [EXTERNAL] [ansible-project] Re: Ansible and Windows Project

Thank you very much Yarno for your insights.

I will look at Powershell and GPO. In theory, I would like something that can 
be version controlled, which GPO aren't not the easiest.

I can always investigate DSC, but I was not really interested in it, since I 
could do the same with an Ansible Playbook and modules outside of the win_dsc 
module.

Thank you again.

I am definitely curious to see what other people are doing!

-Simon

From: ansible-project@googlegroups.com  on 
behalf of Yarno Cobussen 
Sent: August 23, 2019 2:16 PM
To: Ansible Project 
Subject: [EXTERNAL] [ansible-project] Re: Ansible and Windows Project

Hi Simon-Pierre,

GPO's can be managed using PowerShell. Registry based GPO settings 
(administrative templates) can be updated through PS as well. Ansible can be 
used to execute these PS commands. This will help to get you started:
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-2008/ee461027(v=technet.10)

Also, in your setup, using Desired State Configuration could be interesting. 
Just like GPO, it's build into Windows, but it's more lightweight, versatile 
and domain independent. It is, however, not a full replacement for GPO in all 
cases. DSC can be managed using a dedicated Ansible module. This will help you 
decide if it's useful to you:
https://blogs.technet.microsoft.com/ashleymcglone/2017/02/27/compare-group-policy-gpo-and-powershell-desired-state-configuration-dsc/
https://docs.ansible.com/ansible/latest/user_guide/windows_dsc.html

Lastly, I advice against manually setting registry keys. An intermediary tool 
such as GPO or DSC is there for a reason. It helps audit what is set where and 
why, from within a configured system. This makes troubleshooting, reverting a 
key deployment or any small alteration far more comfortable for sysadmins. This 
is especially true for those who do not have a deep understanding of what your 
playbooks did to every system they're responsible for.

Hopefully this helps you decide on what to do.

Regards,
Yarno

On Thursday, 22 August 2019 13:32:16 UTC+2, Simon-Pierre Diamond wrote:
Hi Ansible Community,

It is my first post here. I am coming to get more information about Windows 
management with Ansible.

I have been using Ansible for about a year now, and I am able to manage Windows 
with the WinRM with certificate. My playbooks manage the initial set up for all 
of the Windows servers (Create ansible user, Set DNS, Join AD, Add AD users to 
Local Administrator).

What I am wondering is for GPOs. We can agree that all GPOs or LGPOs are linked 
to Registry Keys in Windows.

At this point I am at a split road. Where I work, we don't have extensive GPOs 
from the domain controller, and our structure is not made so we don't have a 
central Domain Controller. At this point we have maybe 4-5 environment running 
a Domain Controller with Simple AD in AWS or AD in AWS. We are looking at 
potentially having way more in the future. Although we are at a point where we 
need to securely and configure application, users and other stuff. Usually, I 
would go and just make GPOs, but we can also agree that GPOs can come 
repetitive and long to do as it is manual through the GPO manager or AGPM. 
There is no way I can have a central AD to manage the others.

My question for you guys is: should I use Ansible and the 

[ansible-project] Re: loop through a json object

2019-08-27 Thread Nicholas Britton
I got this figured out.  I needed to add a step before, to create a list 
with all the values , then find the max of it.  

On Monday, August 26, 2019 at 12:42:47 PM UTC-5, Nicholas Britton wrote:
>
> Thank you, that has helped alot.   
>
> I was looking at the max option:
>
> - name: debug - show max lun number
> debug:
>   msg: "{{item.lun.lun}}"
> loop: "{{luns.json.data}}"
> when: "{{item.lun.lun | max}}"
>
>
> But it returns the following:
> TASK [debug - show max lun number] 
> 
> fatal: [127.0.0.1]: FAILED! => {"msg": "The conditional check 
> '{{item.lun.lun | max}}' failed. The error was: Unexpected templating type 
> error occurred on ({{item.lun.lun | max}}): 'int' object is not 
> iterable\n\nThe error appears to be in 
> '/home/nbritton/ansible/gts-core-storage-operations/hds/get_luninfo.yml': 
> line 65, column 5, but may\nbe elsewhere in the file depending on the exact 
> syntax problem.\n\nThe offending line appears to be:\n\n\n  - name: debug - 
> show max lun number\n^ here\n"}
>
> The value i am after is the last one in the output here:
>
> TASK [debug new vars] 
> *
> ok: [127.0.0.1] => {
> "msg": "am1vmhost12,CL8-B,15,83,SFTP,6"
> }
>
>
>
>
> On Friday, August 23, 2019 at 3:22:58 PM UTC-5, Nicholas Britton wrote:
>>
>> I am trying to loop through a json object that is returned and list out 
>> key pieces of information, or later on do something with these key peices 
>> of information from each object.  I have been trying to do this with 
>> JMESpath examples but have not had much luck.   Would anyone be able to 
>> help point me in the right direction.
>>
>> For this example i am trying to pull out hostGroup.hostGroupdId, 
>> hostGroup.hostgroupname, ldev.ldevid, lun.lun, lun.lunid
>>
>> Here is a sample of the output returned from json_out.json:
>>
>> TASK [debug lunpaths] 
>> ***
>> ok: [127.0.0.1] => {
>> "msg": {
>> "count": 4,
>> "data": [
>> {
>> "hostGroup": {
>> "hostGroupId": "CL7-A,15",
>> "hostGroupName": "host12",
>> "hostGroupNumber": 15,
>> "hostMode": "VMWARE_EX",
>> "hostModeOptions": [
>> 54,
>> 63
>> ],
>> "portId": "CL7-A",
>> "storageDeviceId": "88600099"
>> },
>> "ldev": {
>> "attributes": [
>> "CVS",
>> "HDT"
>> ],
>> "blockCapacity": 2147483648,
>> "byteFormatCapacity": "1.00 T",
>> "clprId": 0,
>> "dataReductionMode": "disabled",
>> "dataReductionStatus": "DISABLED",
>> "emulationType": "OPEN-V-CVS",
>> "isDefined": true,
>> "isFullAllocationEnabled": false,
>> "isRelocationEnabled": true,
>> "label": "BackupSFTP",
>> "ldevId": 82,
>> "mpBladeId": 0,
>> "numOfUsedBlock": 3096576,
>> "poolId": 0,
>> "status": "NML",
>> "storageDeviceId": "88600099",
>> "tierLevel": "all",
>> "tierLevelForNewPageAllocation": "M",
>> "usedCapacityPerTierLevel1": 1512,
>> "usedCapacityPerTierLevel2": 0
>> },
>> "lun": {
>> "lun": 5,
>> "lunId": "CL7-A,15,5",
>> "storageDeviceId": "886000428027"
>> }
>> },
>> {
>> "hostGroup": {
>> "hostGroupId": "CL7-B,15",
>> "hostGroupName": "host12",
>> "hostGroupNumber": 15,
>> "hostMode": "VMWARE_EX",
>> "hostModeOptions": [
>> 54,
>> 63
>> ],
>> "portId": "CL7-B",
>> "storageDeviceId": "88600099"
>> },
>> "ldev": {
>> "attributes": [
>> "CVS",
>> "HDT"
>> ],
>> "blockCapacity": 2147483648,
>> 

[ansible-project] Attaching/detaching storage domains

2019-08-27 Thread harry devine
We have a Red Hat RHV setup that uses NFS for its storage.  We are moving 
to a Red Hat Hyperconverged solution that uses GlusterFS for its storage.  
We have a Data domain called Migrate that we use to move the VM disks from 
the NFS storage domain to this NFS migrate domain.

What we'd like to do is, via an Ansible Playbook, attach the Migrate domain 
to RHV, move the disk(s) to it, put the Migrate domain back in maintenance, 
detach it, then attach it on the Hyperconverged setup, then import the VM 
and move the disk(s) to the Gluster storage domain.

Anyone have any examples of how to do this?  I'm reading up about 
ovirt_storage_domain at docs.ansible.com, but it seems like the examples 
are very generic.

Thanks for any ideas!
Harry

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0e3a5193-9e50-477e-a633-bce038dd5a05%40googlegroups.com.


Re: [ansible-project] Loop with hostvars groups

2019-08-27 Thread Rafael Tomelin
Hi Vinoth,

Thanks, your recommendation is work.

On Tue, Aug 27, 2019 at 9:10 AM vinoth kumar  wrote:

> Hi
> remove hostvars[host].ansible_hostname and try with
> hostvars[host].ansible_facts.hostname if you are doing it from setup module
> or gayher_facts
>
> If it’s not fixed put your playbook here
>
> On Tue, 27 Aug 2019 at 5:36 PM, Rafael Tomelin 
> wrote:
>
>>
>> Hi,
>>
>> I have an inventory with groups this configuration the DB Servers:
>>
>> [db]
>> 192.168.0.1
>> 192.168.0.2
>> 192.168.0.3
>>
>> I want to do loop the groups and get variable ipaddress in template.j2.
>> My loop is:
>> {% for host in groups['db'] -%}
>> hostall postgres   {{ hostvars[host].ansible_hostname
>> }}/32   trust
>> {% endfor %}
>>
>> My error
>>
>> "msg": "AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars
>> object' has no attribute 'ansible_hostname'",
>>
>> What`s correct configuration?
>>
>>
>>
>> --
>> Atenciosamente,
>>
>> Rafael Tomelin
>> Tel.: 51-984104084
>> Skype: rafael.tomelin
>>
>> LPI ID: LPI000191271
>> Red Hat Certified Engineer
>> Puppet Professional 2017 Certification
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/CAGEUqbCW9GZVwGQ%2BtqQopQBpOAEV-c7_08ud0TWu-AawmEDiRA%40mail.gmail.com
>> 
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAJ%2BRxtRneB6nrP680LhkiQ9WRBJ-r3KDo1u9EVFkzE8MUsbapQ%40mail.gmail.com
> 
> .
>


-- 
Atenciosamente,

Rafael Tomelin
Tel.: 51-984104084
Skype: rafael.tomelin

LPI ID: LPI000191271
Red Hat Certified Engineer
Puppet Professional 2017 Certification

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGEUqbAP4MQ8Gi7-GDhwLsYTZ08EbQu08N-7_m2BjHA22LF3Ow%40mail.gmail.com.


Re: [ansible-project] Loop with hostvars groups

2019-08-27 Thread vinoth kumar
Hi
remove hostvars[host].ansible_hostname and try with
hostvars[host].ansible_facts.hostname if you are doing it from setup module
or gayher_facts

If it’s not fixed put your playbook here

On Tue, 27 Aug 2019 at 5:36 PM, Rafael Tomelin 
wrote:

>
> Hi,
>
> I have an inventory with groups this configuration the DB Servers:
>
> [db]
> 192.168.0.1
> 192.168.0.2
> 192.168.0.3
>
> I want to do loop the groups and get variable ipaddress in template.j2. My
> loop is:
> {% for host in groups['db'] -%}
> hostall postgres   {{ hostvars[host].ansible_hostname
> }}/32   trust
> {% endfor %}
>
> My error
>
> "msg": "AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars
> object' has no attribute 'ansible_hostname'",
>
> What`s correct configuration?
>
>
>
> --
> Atenciosamente,
>
> Rafael Tomelin
> Tel.: 51-984104084
> Skype: rafael.tomelin
>
> LPI ID: LPI000191271
> Red Hat Certified Engineer
> Puppet Professional 2017 Certification
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAGEUqbCW9GZVwGQ%2BtqQopQBpOAEV-c7_08ud0TWu-AawmEDiRA%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAJ%2BRxtRneB6nrP680LhkiQ9WRBJ-r3KDo1u9EVFkzE8MUsbapQ%40mail.gmail.com.


[ansible-project] Loop with hostvars groups

2019-08-27 Thread Rafael Tomelin
Hi,

I have an inventory with groups this configuration the DB Servers:

[db]
192.168.0.1
192.168.0.2
192.168.0.3

I want to do loop the groups and get variable ipaddress in template.j2. My
loop is:
{% for host in groups['db'] -%}
hostall postgres   {{ hostvars[host].ansible_hostname
}}/32   trust
{% endfor %}

My error

"msg": "AnsibleUndefinedVariable: 'ansible.vars.hostvars.HostVarsVars
object' has no attribute 'ansible_hostname'",

What`s correct configuration?



-- 
Atenciosamente,

Rafael Tomelin
Tel.: 51-984104084
Skype: rafael.tomelin

LPI ID: LPI000191271
Red Hat Certified Engineer
Puppet Professional 2017 Certification

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAGEUqbCW9GZVwGQ%2BtqQopQBpOAEV-c7_08ud0TWu-AawmEDiRA%40mail.gmail.com.


[ansible-project] ansible error 'first argument must be string or compiled pattern'

2019-08-27 Thread Fae Az


I have this code in my playbook:

- hosts: standby
  remote_user: root
  tasks:
  - name: replace hostname in config
replace:
  path: /opt/agentd.conf
  regexp: #\s+Hostname\=
  replace: Hostname={{hname}}
  backup: yes
  - name: add database array in files
lineinfile:
  path: /opt/zabbix_agent/share/scripts/{{ item }}
  line: 'DBNAME_ARRAY=( {{dbname}} )'
  insertafter: DB2PATH=/home/db2inst1/sqllib/bin/db2
  backup: yes
  with_items:
   - Connections
   - HadrAndLog
   - Memory
   - Regular
 - name: restart service
   shell: /etc/init.d/agent restart
   register: command_output
   become: yes
   become_user: root
   tags: restart
 - debug: msg="{{command_output.stdout_lines}}"
 tags: set_config_st

it will replace # Hostname= in a config file with Hostname= givenhostname and 
add an array in 4 scripts. array is the name of given database. then it 
will restart the agent to apply the changes.
when i run this command:

ansible-playbook -i /Ansible/inventory/hostfile /Ansible/provision/nconf.yml 
--tags set_config_st --extra-vars "hname=fazi dbname=fazidb"

i get this error:

first argument must be string or compiled pattern
i searched a bit but couldn't find the reason. what should i do?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5b82a515-c48f-4513-9769-d1abda4b38e6%40googlegroups.com.