Re: [ansible-project] Issue with first playbook

2019-09-07 Thread Zolvaring
Do you know what version of edgeos you are connecting to? The module docs
for edgeos_facts say it was tested on 1.9.7.

It looks like the module is failing but I can't tell  why it is getting the
assertion error over socket_path. I would try limiting your gather subset
to see which set of facts is causing the problem you may not need them.

For making the error more readable I think the debug stdout callback will
do that but I don't think it's going to get any more information.
Unfortunately it looks like it's a problem with the module running the
target (I don't have experience with edgeos)

On Fri, Sep 6, 2019, 10:57 PM elogateumsato  wrote:

> I have a Ubiquiti Edge Router X on my network and was playing around with
> running playbooks on it.
>
> i'm trying to run the following playbook:
>
> ---
>> -
>> name: show current configuration
>> hosts: routers
>> tasks:
>> - name: get facts
>>   edgeos_facts:
>>   gather_subset: all
>>
>> by default (i've turned off strict host key checking)  and run the
>> playbook and get the following error:
>>
>> root@ansible:~/My_Ansible# ansible-playbook -i router edge_facts.yml
>>
>> PLAY [show current configuration]
>> **
>>
>> TASK [Gathering Facts]
>> *
>> ok: [EdgeRouter]
>>
>> TASK [get facts]
>> ***
>> fatal: [EdgeRouter]: FAILED! => {"changed": false, "module_stderr":
>> "Shared connection to 10.1.1.1 closed.\r\n", "module_stdout": "Traceback
>> (most recent call last):\r\n  File
>> \"/home/USER/.ansible/tmp/ansible-tmp-1567834372.68-68684870289821/AnsiballZ_edgeos_facts.py\",
>> line 114, in \r\n_ansiballz_main()\r\n  File
>> \"/home/USER/.ansible/tmp/ansible-tmp-1567834372.68-68684870289821/AnsiballZ_edgeos_facts.py\",
>> line 106, in _ansiballz_main\r\ninvoke_module(zipped_mod, temp_path,
>> ANSIBALLZ_PARAMS)\r\n  File
>> \"/home/USER/.ansible/tmp/ansible-tmp-1567834372.68-68684870289821/AnsiballZ_edgeos_facts.py\",
>> line 49, in invoke_module\r\nimp.load_module('__main__', mod, module,
>> MOD_DESC)\r\n  File
>> \"/tmp/ansible_edgeos_facts_payload_6VDe7q/__main__.py\", line 311, in
>> \r\n  File
>> \"/tmp/ansible_edgeos_facts_payload_6VDe7q/__main__.py\", line 299, in
>> main\r\n  File \"/tmp/ansible_edgeos_facts_payload_6VDe7q/__main__.py\",
>> line 187, in populate\r\n  File
>> \"/tmp/ansible_edgeos_facts_payload_6VDe7q/__main__.py\", line 110, in
>> populate\r\n  File
>> \"/tmp/ansible_edgeos_facts_payload_6VDe7q/ansible_edgeos_facts_payload.zip/ansible/module_utils/network/edgeos/edgeos.py\",
>> line 74, in run_commands\r\n  File
>> \"/tmp/ansible_edgeos_facts_payload_6VDe7q/ansible_edgeos_facts_payload.zip/ansible/module_utils/network/edgeos/edgeos.py\",
>> line 40, in get_connection\r\n  File
>> \"/tmp/ansible_edgeos_facts_payload_6VDe7q/ansible_edgeos_facts_payload.zip/ansible/module_utils/network/edgeos/edgeos.py\",
>> line 54, in get_capabilities\r\n  File
>> \"/tmp/ansible_edgeos_facts_payload_6VDe7q/ansible_edgeos_facts_payload.zip/ansible/module_utils/connection.py\",
>> line 122, in __init__\r\nAssertionError: socket_path must be a value\r\n",
>> "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}
>>
>> PLAY RECAP
>> *
>> EdgeRouter : ok=1changed=0unreachable=0
>> failed=1skipped=0rescued=0ignored=0
>>
>> ---
>
>
> 
>
> 
>
>  if i run the command with - i get the following under 'task' :
> https://pastebin.com/E42YxHE0
>
>  after some googling (i've tried changing `ControlPersist=60s` doesn't
> work)  While looking how to make errors more readable i found something
> that said in `ansible.cfg` change `stdout_callback = minimal` and I
> actually get back the data, however it still errors out.
>
>
> 
>
>  How do I make the error more readable?
>
> --
> 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/45409573-9e8c-4bd7-b60c-08fbcb5cc3f7%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To 

Re: [ansible-project] Re: Ansible and Satellite 6.4 - Waiting for Promote To Finish

2019-09-07 Thread Zolvaring
Okay, looking more closely I think I see. I don't believe "results" becomes
populated in a loop object until the end of the first iteration and with a
retry technically you have never ended that first iteration. What I would
do then is this:

include_tasks: register_environment
loop:
  - 3
  - 4
  etc


---
# file: register_environment.yml

- task:
  your whole task as you wrote it with retries

This will bring the task out of a loop by using the file include and I
believe it will handle register normally (as in "result" will be available
for retry for initial iteration)


On Fri, Sep 6, 2019, 10:14 AM Cade Lambert  wrote:

> I tested that just now.  It doesn't work. The API doesn't send a response
> about the status of the promote task.  When I make the call to promote, it
> immediately responds with info that it started, and that's all.  So the
> solution Kai provided really just keeps sending the same API request using
> the same loop item, because it never gets a response back from the API
> about result.
>
> root@tower /etc/ansible/playbooks $ ansible-playbook test.yml
>
> PLAY [localhost]
> 
>
> TASK [Gathering Facts]
> **
> ok: [localhost]
>
> TASK [Promote new RHEL7 version to Lifecycle Environments]
> **
> FAILED - RETRYING: Promote new RHEL7 version to Lifecycle Environments (10
> retries left).
> FAILED - RETRYING: Promote new RHEL7 version to Lifecycle Environments (9
> retries left).
> FAILED - RETRYING: Promote new RHEL7 version to Lifecycle Environments (8
> retries left).
> FAILED - RETRYING: Promote new RHEL7 version to Lifecycle Environments (7
> retries left).
> FAILED - RETRYING: Promote new RHEL7 version to Lifecycle Environments (6
> retries left).
> FAILED - RETRYING: Promote new RHEL7 version to Lifecycle Environments (5
> retries left).
> FAILED - RETRYING: Promote new RHEL7 version to Lifecycle Environments (4
> retries left).
> FAILED - RETRYING: Promote new RHEL7 version to Lifecycle Environments (3
> retries left).
>
>
> --
> 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/4a97a600-72be-40eb-a712-b637736978d6%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/CAKEXu84M23WzuCbm_QDz%2BAYz%3DO2zbaN1vywdcba4AadgiCAFCw%40mail.gmail.com.


Re: [ansible-project] Re: Ansible and Satellite 6.4 - Waiting for Promote To Finish

2019-09-06 Thread Zolvaring
I think Kai's suggestion is correct, don't know much about your specific
use case, but I've had similar issues looping with return values. The
reason is on there first check the call hasn't been made yet and "results"
won't exist you're right, but on subsequent calls within that loop it will,
so that extra clause should fix that error.

On Fri, Sep 6, 2019, 7:52 AM Cade Lambert  wrote:

> Yeah, it's not defined because it's not a value that's returned when the
> API call is sent.  I'm not sure there's a way to do what I'm trying to do
> with a 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2ec91a91-ced2-4c58-9380-b343b6b3acf8%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/CAKEXu87eXZ-Xf6B5v1wa%3DTGbDPLhG9ADvi%3Duoo32Kd4%2B%3DWZ7zg%40mail.gmail.com.


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

2019-09-04 Thread Zolvaring
Looking at your posted output, I'm wondering if "Reason: PGP Decryption:" 
isn't the line you get after you enter a password? I noticed the extra line 
and nothing else on the cli to indicate a response. I don't fully 
understand the pexpect regex implementation here as it seems weird to me 
whenever I touch expect, but generally capturing as little as possible 
works. Instead of ".*Please enter your keybase passphrase to unlock the 
secret key for.*" I would try "key for" and if you need something more 
specific then work backwards from there.

There's the bizarre and unfortunate chance that it's also using the actual 
printed username as part of the prompt but I'm assuming that's not so, 
otherwise that'd be harder.

On Tuesday, August 27, 2019 at 7:25:06 PM UTC-7, Andrew Graham wrote:
>
> 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/3908a18d-952e-47ef-8b3c-874f5812c105%40googlegroups.com.


[ansible-project] Re: Set SELinux to permissive mode and reboot.

2019-09-04 Thread Zolvaring
I'm almost positive you'd have to register the SELinux task return to get 
this to work, 'reboot_required' is not going to exist outside of that 
scope, I think what you would need is:

---
- name: Set SELinux to permissive mode.
  selinux:
policy: targeted
state: permissive
  register: set_selinux
  when: ansible_selinux_python_present|bool
- name: Reboot
  selinux:
  when: set_selinux.reboot_required|bool

The return values for the selinux module are documented here 
https://docs.ansible.com/ansible/latest/modules/selinux_module.html, and 
reboot_required is among them. Hope this helps.

On Wednesday, September 4, 2019 at 6:46:33 AM UTC-7, Keith Mills wrote:
>
> Hello All,
>
> I need to set SELinux to permissive mode and reboot. When I run my 
> playbook I get an error.
>
> Playbook:
>
> ---
> - name: Set SELinux to permissive mode.
>   selinux:
> policy: targeted
> state: permissive
>   when: ansible_selinux_python_present|bool
> - name: Reboot
>   selinux:
>   when: reboot_required|bool
>
> Error:
>
> TASK [buildservers : Reboot] 
> 
> fatal: [abls15ex]: FAILED! => {"msg": "The conditional check 
> 'reboot_required|bool' failed. The error was: error while evaluating 
> conditional (reboot_required|bool): 'reboot_required' is undefined\n\nThe 
> error appears to be in 
> '/home/jamekeit/ds9/roles/buildservers/tasks/selinux.yaml': line 7, column 
> 3, but may\nbe elsewhere in the file depending on the exact syntax 
> problem.\n\nThe offending line appears to be:\n\n  when: 
> ansible_selinux_python_present|bool\n- name: Reboot\n  ^ here\n"}
>
>
> Can anyone help?
>

-- 
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/33a662b0-4cde-4033-8717-ab9204febb8e%40googlegroups.com.


[ansible-project] Re: Requires Help ,using Python for accessing dictionary values from yaml file

2019-09-04 Thread Zolvaring
Hey Pawan,

I got the laptop out and tried:
ansible-playbook testplay.yml -i localhost, -e "@testvars.yml"

and got:

ERROR! Invalid extra vars data supplied. '@testvars.yml' could not be made 
into a dictionary

After digging, I found: 
https://github.com/ansible/ansible/issues/38415
https://github.com/ansible/ansible/pull/31433

The above issues (Recent as of Dec 2018) point out that YAML was never 
accepted as CLI args, though at one point the documentation erroneously 
claimed it was.

What I did was this:
---
- hosts: 127.0.0.1
  connection: local
  vars_files:
- "{{ TEST }}"
  tasks:


- name: Testing
  debug:
msg: "{{ releases }}"

---
- releases:
gotcha:
  file_name: gtp.tar
  md5: 11f6987275613ca3ecf832ea59c1
  product_name: gotcha
  product_number: GTP 8881
  release_candidate: rc19
  version: 19.0.0
tp:
  file_name: tpr.tar
  md5: ebd7742ed8fff0472733c0cd8e
  product_name: tp
  product_number: TTP 8057
  release_candidate: rc25
  version: 25.0.0
device_name:
  file_name: dna.tar
  md5: e464e69a07123de075778aa9b7
  product_name: device_name
  product_number: DNP 6746
  release_candidate: rc25
  version: 25.0.0


And then ran:
ansible-playbook testplay.yml -i localhost, -e "TEST=testvars.yml"

And got:
TASK [Gathering Facts] 
**
ok: [localhost]

TASK [Testing] 
**
ok: [localhost] => {
"msg": {
"device_name": {
"file_name": "dna.tar",
"md5": "e464e69a07123de075778aa9b7",
"product_name": "device_name",
"product_number": "DNP 6746",
"release_candidate": "rc25",
"version": "25.0.0"
},
"gotcha": {
"file_name": "gtp.tar",
"md5": "11f6987275613ca3ecf832ea59c1",
"product_name": "gotcha",
"product_number": "GTP 8881",
"release_candidate": "rc19",
"version": "19.0.0"
},
"tp": {
"file_name": "tpr.tar",
"md5": "ebd7742ed8fff0472733c0cd8e",
"product_name": "tp",
"product_number": "TTP 8057",
"release_candidate": "rc25",
"version": "25.0.0"
}
}
}

It looks to me like if you want to dynamically supply the vars file as YAML 
on cli, that is your best bet. Use 'vars_files' with a dynamic var and 
declare that var on the cli

On Monday, September 2, 2019 at 3:18:42 PM UTC-7, Pawan Kumar wrote:
>
> Using Python script  to access values from yaml dictionary & print some of 
> the values as list . 
>
> For Example -  Parse the each key and extract the “product_name”, 
> “release_candidate” and “version“ & Print results as list
>
> The yaml file looks like 
>
>
>
> - releases:
> - gotcha:
> file_name: gtp.tar
> md5: 11f6987275613ca3ecf832ea59c1
> product_name: gotcha
> product_number: GTP 8881
> release_candidate: rc19
> version: 19.0.0
> - tp:
> file_name: tpr.tar
> md5: ebd7742ed8fff0472733c0cd8e
> product_name: tp
> product_number: TTP 8057
> release_candidate: rc25
> version: 25.0.0
>

-- 
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/9855ec15-da66-44dc-91d8-f07201533089%40googlegroups.com.


Re: [ansible-project] Requires Help ,using Python for accessing dictionary values from yaml file

2019-09-03 Thread Zolvaring
Hm okay I'm not sure that would work, but gojng back to your original example, 
have you tried passing the yaml file like this when you run the playbook?

"--extra-vars=@your_yaml_file.yml" 

Reading I think that should work the same as running it "with_vars"

-- 
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/24f29a51-e0df-4382-a983-7d8beebcc94f%40googlegroups.com.


Re: [ansible-project] Requires Help ,using Python for accessing dictionary values from yaml file

2019-09-02 Thread Zolvaring
I think what you want to do to use cli is specify the path as your var name
just like your example, and then in your code when you invoke the variable,
use the file lookup:

- set_fact:
your_fact: "{{ lookup('file', INV_VAR) }}"

I'm not clear if you will need to do something beyond that for it to
naturally interpret the yaml object though there's a chance you'll still
end up with a string.



On Mon, Sep 2, 2019, 4:09 PM Pawan Kumar  wrote:

> My Ansible code works fine , if i call dictionary values from file .
>
> But requires guidance , how using the yaml file to pass as argument as INV
> file command line to execute playbook:
>
> something like :
>
> "ansible-playbook test.yml -e INV_FILE=latest123.yaml"
>
> On Tuesday, September 3, 2019 at 4:31:37 AM UTC+5:30, Pawan Kumar wrote:
>>
>> Hi Dick,
>>
>> Thanks for replying .
>>
>> Well said , i was working with Ansible to parse values from dictionary
>> file .
>>
>> working with the following ansible playbook
>>
>>
>>
>> ---
>> - hosts: 127.0.0.1
>>   connection: local
>>   vars_files:
>> - latest123.yaml
>>   tasks:
>>
>> - name: Printing "releases" value from yaml file...
>>   debug:
>> msg: "Name of the Product is {{ releases[item]['product_name']
>> }}  it's release candidate: {{ releases[item]['release_candidate'] }} &
>> version: {{ releases[item]['version'] }}"
>>   with_items: "{{ releases.keys() }}"
>>
>>
>>
>>
>> from the following latest123.yaml file
>>
>>
>> ---
>> - releases:
>> gotcha:
>>   file_name: gtp.tar
>>   md5: 11f6987275613ca3ecf832ea59c1
>>   product_name: gotcha
>>   product_number: GTP 8881
>>   release_candidate: rc19
>>   version: 19.0.0
>> tp:
>>   file_name: tpr.tar
>>   md5: ebd7742ed8fff0472733c0cd8e
>>   product_name: tp
>>   product_number: TTP 8057
>>   release_candidate: rc25
>>   version: 25.0.0
>> device_name:
>>   file_name: dna.tar
>>   md5: e464e69a07123de075778aa9b7
>>   product_name: device_name
>>   product_number: DNP 6746
>>   release_candidate: rc25
>>   version: 25.0.0
>>
>>
>>
>>
>> On Tuesday, September 3, 2019 at 4:06:16 AM UTC+5:30, Dick Visser wrote:
>>>
>>> Hi
>>>
>>> Kindly explain where ansible comes into play in this story?
>>>
>>> On Tue, 3 Sep 2019 at 00:18, Pawan Kumar  wrote:
>>>
 Using Python script  to access values from yaml dictionary & print some
 of the values as list .

 For Example -  Parse the each key and extract the “product_name”,
 “release_candidate” and “version“ & Print results as list

 The yaml file looks like



 - releases:
 - gotcha:
 file_name: gtp.tar
 md5: 11f6987275613ca3ecf832ea59c1
 product_name: gotcha
 product_number: GTP 8881
 release_candidate: rc19
 version: 19.0.0
 - tp:
 file_name: tpr.tar
 md5: ebd7742ed8fff0472733c0cd8e
 product_name: tp
 product_number: TTP 8057
 release_candidate: rc25
 version: 25.0.0

 --
 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/cdcb12c4-b6f6-4dbb-be42-b781e7d576d3%40googlegroups.com
 
 .

>>> --
>>> Sent from a mobile device - please excuse the brevity, spelling and
>>> punctuation.
>>>
>> --
> 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/486f2e57-bed0-4a07-a841-81d090665633%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/CAKEXu86Q4-u2c9B1PQxpSxvDzNXvDJt_mTLNOoVUa8kzVNq%2B7Q%40mail.gmail.com.


Re: [ansible-project] Re: Why is this telling me the variable is undefined?

2019-08-26 Thread Zolvaring
Hello,

I was having a moment earlier when I read your path as an actual variable
that was my mistake. To be more helpful though, I replicated your code on
my setup and ran into the same error. On checking the docs I saw that
read_csv was added in 2.8, and after updating to 2.8 the "no action
detected in task" error is gone.

Hopefully this helps

On Mon, Aug 26, 2019 at 3:15 PM Chrono 7  wrote:

>
>  Appreciate the responses so far everyone. I've indented the *path *line
> as suggested but still get the following error:
>
>
> ERROR! no action detected in task. This often indicates a misspelled
> module name, or incorrect module path.
>
> The error appears to have been in 'system_info.yaml': line 7, column 7,
> but may
> be elsewhere in the file depending on the exact syntax problem.
>
> The offending line appears to be:
>
>   tasks:
>   - name: Read the CSV & Set Values
> ^ here
>
>
> Here's the latest of what my file currently looks like:
>
>
> ---
>
> - name: Import CSV Containing Info For System(s) To Prep
>   hosts: 127.0.0.1
>
>   tasks:
>   - name: Read the CSV & Set Values
> read_csv:
>   path: systems.csv
> register: systems
> delegate_to: localhost
>
>- set_fact:
>IP: "{{ systems.list.1.IPAddress }}"
>
>
> A couple things I've tried:
>
> 1. I've tried playing around with the indentations of the *- name *and *-
> set_fact *where I've increased it by one indent.
> 2. I've tried referencing the absolute path of the *systems.csv *file
> within *path:* in case it wasn't able to find this for whatever reason.
> The csv file itself is in the same directory as the playbook as well, and
> since I'm not referencing a variable at this point, I'm not sure that I'd
> have to define a *systems *variable itself containing the path to the CSV
> file
>
> I'm currently running *2.5.1 *as well and admittedly am new to 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/fd62e720-abea-4810-b281-4fa687e2dd6c%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/CAKEXu84%2BqbEqBmAG6HtBTwvLyNYxJBaUf3OnJfZpuGybLGqx1g%40mail.gmail.com.


[ansible-project] Why is this telling me the variable is undefined?

2019-08-26 Thread Zolvaring
Your original spacing looks fine other than missing the dash for set fact. The 
original error is indicating that the "system" doesn't exist when your CSV read 
task looks for "system.csv". I would check that "system.csv" is defined and add 
this before the csv read task to troubleshoot:

- debug:
var: system
- debug:
var: system.csv

-- 
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/83026b47-7dd8-4cce-8f3e-97aae8ca9d99%40googlegroups.com.


Re: [ansible-project] Unable to get value of variable from another Play in Ansible

2019-08-22 Thread Zolvaring
Unfortunately play variables do not persist in between plays by design in
Ansible, generally I would try and group the tasks in a play together but
you can write your vars to files on the local Host or remote node in play 2
and then read that file in play 3. One thing I can also suggest although I
don't have a laptop to test currently is:

Play2:
Hosts: test
Tasks:
  set_fact:
myvar: foo

Play3
Hosts: test
Tasks:
  set_fact:
myvar: "{{ hostvars['test']['myvar'] }}"


^ that might work as I believe hostvars once defined will be carried
throughout execution

On Thu, Aug 22, 2019, 12:26 PM Mohtashim S  wrote:

> I wish to obtain the value of "f_APP" variable of Play 2 into Play 3.
>
>
> Below is my playbook which case be used as a testcase:
>
>
> - name: "Play 1"
>   hosts: localhost
>   tasks:
>
>- add_host: name={{ item }}
> groups=dest_nodes
> ansible_user={{ USER }}
>  with_items: "{{ Dest_IP.split(',') }}"
>
>
> - name: "Play 2"
>   hosts: dest_nodes
>   user: "{{ USER }}"
>   tasks:
>
>- set_fact:
>f_APP: "Yellow"
>
> - name: "Play 3"
>
>   hosts: localhost
>   user: "{{ USER }}"
>
>   vars:
> dbfiledet: "{{ hostvars['dest_nodes']['f_APP'] }}"
>
>   tasks:
>- debug: msg="{{ dbfiledet.stdout }}"
>
>
>
>
>
>
>
> I get the below error for my attempt:
>
>
> playbook RUN command:
>
>
> ansible-playbook variabletest.yml -e "USER=user1
> Dest_IP=10.17.44.26,10.17.54.26"
>
> [WARNING]: provided hosts list is empty, only localhost is available. Note
> that the implicit localhost does not match 'all'
>
>
> PLAY [Play 1]
>
>
> TASK [Gathering Facts]
> **
> ok: [localhost]
>
>
> TASK [add_host]
> *
> changed: [localhost] => (item=10.17.44.26) changed: [localhost] =>
> (item=10.17.54.26)
>
>
> PLAY [Play 2]
>
>
> TASK [Gathering Facts]
> **
> ok: [10.17.54.26] ok: [10.17.44.26]
>
>
> TASK [set_fact]
> *
> ok: [10.17.44.26] ok: [10.17.54.26]
>
>
> PLAY [Play 3]
>
>
> TASK [Gathering Facts]
> **
> ok: [localhost]
>
>
> TASK [debug]
> 
> fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an
> undefined variable. The error was: \"hostvars['dest_nodes']\" is
> undefined\n\nThe error appears to be in 'variabletest.yml': line 36, column
> 6, but may\nbe elsewhere in the file depending on the exact syntax
> problem.\n\nThe offending line appears to be:\n\n\n - debug: msg=\"{{
> dbfiledet.stdout }}\"\n ^ here\nWe could be wrong, but this one looks like
> it might be an issue with\nmissing quotes. Always quote template expression
> brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo
> }}\n\nShould be written as:\n\n with_items:\n - \"{{ foo }}\"\n"}
>
>
> PLAY RECAP
>
>
> 10.17.44.26 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0
> ignored=0
>
> 10.17.54.26 : ok=2 changed=0 unreachable=0 failed=0 skipped=0 rescued=0
> ignored=0 localhost
>
> : ok=3 changed=1 unreachable=0 failed=1 skipped=0
>
> rescued=0 ignored=0
>
>
> I'm on the latest version of ansible and python 2.7.5
>
>
> Can someone suggest what is wrong and how can i get the value for the
> variable in Play 3 please ?
>
> --
> 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/36a39c4b-1e5f-4b21-b9c4-89c1f9941452%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/CAKEXu87obqohw%3D2f1aN2njrVtFueL8J%2BN001C87%2ByXqKvNk0Aw%40mail.gmail.com.


Re: [ansible-project] Importing list file ?

2019-08-22 Thread Zolvaring
I'm not able to test this at the moment, but I think the file lookup is
what you want:

Mylist: "{{ lookup('file', '/path/to/my/yaml/list') }}"

On Thu, Aug 22, 2019, 12:34 PM Tuyen Nguyen  wrote:

> Hi
>
> I am using the win_updates module and I want to include a list of approved
> patches in the whitelist option.  I have the list of all my approved
> patches in a file already, and I would like to know if and how I can import
> this file to use?
>
> As in example, can I import the list somehow to be a variable called
> patchlist ?
>
> And then in the win_updates module, I could do
>
> win_updates:
>   category_name:
> - SecurityUpdates
> - CriticalUpdates
> - UpdatesRollups
>   state: installed
>   whitelist: {{ patchlist }
>   reboot: yes
>
>
>
>
> --
> 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/96e2dda9-3c74-4894-aed6-cf350c18c7b6%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/CAKEXu854WEaEULKpUK_qBPe%3D%3DnUQuObrfSXkNy03_3OK%3DxsuNQ%40mail.gmail.com.


[ansible-project] 'Unknown host key error' only happens when running a playbook

2019-08-22 Thread Zolvaring
I don't know why the Ansible playbook would respond differently to the host key 
unless it's not running as the same user that you ssh with, so someone else 
will hopefully answer that but what I can suggest if you're willing to forego 
host key checking you can run the play with 'export 
ANSIBLE_HOST_KEY_CHECKING=False', there is also an option for this you can set 
in the configuration file. Obviously you can also try ssh-keyscan and see if 
the host keys are different from your known hosts file, but the env var will 
skip that check altogether (obvious security implications)

-- 
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/7b990313-7b47-47a0-b494-23c973417a1c%40googlegroups.com.


[ansible-project] Re: Some user of ansible_user

2019-08-21 Thread Zolvaring
Ah I missed your detail about serial usage, but am not sure how you could do 
that. You could import or include a play with some sort of loop, or maybe 
registering a var after the final task and setting ansible_ssh_user to that var 
if it exists prior to the first task?

-- 
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/792af329-9104-4b15-b946-1e3cce4d8992%40googlegroups.com.


[ansible-project] Re: Some user of ansible_user

2019-08-21 Thread Zolvaring
I'm confused what you want to do when you use a second user. If you want 
fallback users, I don't know of a simple built in way but have gotten it to 
work looping user/pass /key combos with gather facts or a shell "sudo -l" 
command and register. Then loop through your registered var with set_facts and 
it's possible to set for each host the first successful credential set that 
worked before continuing the play.

If you want different tasks to be run with different users you can use become 
and become_user.

-- 
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/8bc9d204-e6be-4a84-893c-4960f519bcea%40googlegroups.com.


Re: [ansible-project] Can’t reach a server?

2019-08-19 Thread Zolvaring
Do you have the host your connecting Ansible to configured in inventory? If you 
just pass the host as a limit but it's not in inventory Ansible won't know what 
you mean, try "-i "target-host, --limit "target-host" to simulate an inventory 
file or use an inventory file and put the host in question inside (assuming you 
haven't already just a guess) 

-- 
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/a353fa25-d67a-462a-ab4a-4fdd8deffd8c%40googlegroups.com.


Re: [ansible-project] "PUTTING" or http PUT interacting with JFrog Artifactory

2019-08-16 Thread Zolvaring
To put or post a file to an API I would usually use the uri module. Are you
able to explain more what it seems to be missing or post an example? Thanks

On Fri, Aug 16, 2019, 5:08 AM GM  wrote:

> Hey everyone - if I was going to use an Ansible module to push or PUT a
> file into say JFrog Artfactory, using an API key, which of the Ansible
> modules would be best? I have looked at the uri module and the net_put but
> those do not seem to have the functionality that I would need.
>
> I see get_url but that seems to be for the direction from the destination
> to the source.
>
> Can anyone shed some light? Which module would be best for this job? I
> have never had to do this before and I'm a little lost.
>
> Thanks - Glen
>
> --
> 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/a3fe4bd4-cf3f-4789-9c89-4fd55d2b36eb%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/CAKEXu85uXz%3D323DAJDCXe2FFfwCm2%2Bk19F1eaamnW8xFRKM4Mg%40mail.gmail.com.


[ansible-project] What is the best way to manage machines that aren't defined as hosts?

2019-08-15 Thread Zolvaring
Seeing that you may want to loop through actual guests, I would still define 
them as Ansible inventory hosts if you know them ahead of time, and if you need 
to run tasks from a different host by invoking VMware module then try:

- name: do a thing to a guest
  vmware_module:
regular_module_args
  delegate_to: localhost (or somewhere else)

The end result will still naturally loop your inventory but will run from 
whichever host you delegate the commands to.

-- 
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/5823722d-4152-48ad-8b0b-b288e9604b8a%40googlegroups.com.


[ansible-project] What is the best way to manage machines that aren't defined as hosts?

2019-08-15 Thread Zolvaring
I'm not sure I understand fully, but none of the hosts you are configuring need 
Ansible to be installed for you make changes remotely. Instead of defining your 
hosts in a CSV, define your hosts as part of Ansible inventory and your tasks 
will loop through them naturally. You can also group hosts as you had 
mentioned, and run task or assign vars to specific groups, just as you had in 
your example. To execute a play only on remote esxi servers one way is:

- name: configure esxi hosts
  hosts: esxi-hosts
  roles:
 - your roles here

If I run this play and have 5 esxi hosts in my inventory group, then this will 
run all roles or tasks each time for each of those 5 servers in parallel

Making use of group_vars files and host_vars files can change the play vars 
based on the group.

-- 
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/e1640dc5-3875-46f2-95f2-fe3f9efc4819%40googlegroups.com.


Re: [ansible-project] What is the best way to manage machines that aren't defined as hosts?

2019-08-15 Thread Zolvaring
I'm not sure I understand fully, but none of the hosts you are configuring
need Ansible to be installed for you make changes remotely. Instead of
defining your hosts in a CSV, define your hosts as part of Ansible
inventory and your tasks will loop through them naturally. You can also
group hosts as you had mentioned, and run task or assign vars to specific
groups, just as you had in your example. To execute a play only on remote
esxi servers one way is:

- name: configure esxi hosts
  hosts: esxi-hosts
  roles:
 - your roles here

If I run this play and have 5 esxi hosts in my inventory group, then this
will run all roles or tasks each time for each of those 5 servers in
parallel

Making use of group_vars files and host_vars files can change the play vars
based on the group.


On Thu, Aug 15, 2019, 9:15 PM Kurt Robinson  wrote:

> I intend to Ansible to run deployment configuration on a number of Dell
> ESXi hosts in VMware using VMware and OpenManage modules.
>
> In my past ansible training, my playbooks have always run from hosts that
> I have defined in an inventory file. The machines I wish to configure don't
> have ansible installed so they will be managed from the localhost node.
>
> My question is, what is the best practice in running configuration tasks
> on these machines that aren't actual hosts within ansible?
>
> Currently, I am thinking of creating a csv file which will contain the
> host information, then loop through each host and run my tasks to run on
> each host using read_csv.
>
>
>
> pseudo:
>
> - name: Read csv and send to task
>   csv_read: csvname.csv
>   task:
> - taskname
>   passvar:
> - csv.hostname
>
> 
>
> - name : Run task
>   loop: name in csv.hostnames
> do: something
>
>
>
> To me this seems like I am under-engineering the solution a bit. Is there
> a better way I can do this?
>
> Would I be able to add the list of hosts that I want to configure to an
> inventory file, then reference a group for which I will run my
> configurations on?
>
> E.g.
>
> inventory
>
> [management]
> 10.0.0.1
> 10.0.0.2
>
> [database]
> 10.1.0.1
> 10.1.0.2
>
> __
>
> - name: Set DNS on hosts
>   vmware_module:
> hostname: '{{ management group }}'
> dns: 1.2.3.4
>
>
>
> Thanks for taking the time.
>
>
> --
> 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/2c702252-eae3-461e-842f-989e80d88537%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/CAKEXu85Ga7EadHRB%3DyP8hCQqy7S%2BTqCKmkCp%2BTj5CV10LpL5Ew%40mail.gmail.com.


[ansible-project] Re: Difficulty differencing list with integers vs list with strings.

2019-08-15 Thread Zolvaring
On closer examination I dropped a parenthesis entering this in, so for 
clarity:

difference_list: >-
{{ numbers_as_integers |
difference(numbers_as_strings |
map(attribute='whatever_attribute_you_may_need') |
map('int') |
list) }}

On Thursday, August 15, 2019 at 7:03:50 PM UTC-7, Zolvaring wrote:
>
> Would something like this syntax help?
>
>
> set_fact:
>   difference_list: >-
> {{ numbers_as_integers |
> difference(numbers_as_strings |
> map(attribute='whatever_attribute_you_may_need') |
> map('int') |
> list }}
>
> ^ What that should do for the list of numbers as strings, is filter dicts 
> into a pure list based on attribute (not clear if you need this or not, if 
> you have a pure list of integers as strings you can remove that part 
> obviously), the second map will apply the int filter to all members of your 
> list, and then finally make it iterable with list. I was only able to test 
> this briefly but it seemed to work for me if I understand what you're 
> trying to do.
>
> On Thursday, August 15, 2019 at 3:09:03 PM UTC-7, Auralan wrote:
>>
>> Hi everyone,
>>
>> I've been struggling to get the difference between 2 lists in Ansible. 
>> List 1 contains numbers as integers. List 2 contains numbers as strings.
>> These obviously cannot be filtered with difference(). 
>>
>> Does anyone know a workaround? Or a point where I can make a change in my 
>> parsing to remediate this difference?
>> We are using Ansible 2.7.10. Upgrading is an option if needed. My setup 
>> is below.  Thank you for your time!
>>
>>
>>
>> List 1 comes from parsing a JSON document.
>>
>>
>>   - name: "Create list from JSON source."
>> set_fact:
>>   cmdb_list: "{{ cmdb_call.json.results | map(attribute='vid') | list 
>> }}"
>>
>> # Debug of cmdb_list. Output shortened for readability.
>> ok: [localhost] => {
>> "msg": [
>> [
>> 2141, 
>> 2142, 
>> 2143
>> ]
>> ]
>> }
>>
>>
>>
>> List 2 comes from parsing a XML document in 2 steps.
>>
>>   - name: "Create list from XML source. Step 1."
>> xml:
>>   xmlstring: "{{ device_call.ansible_facts.ansible_net_config }}"
>>   xpath: //vlan-id
>>   content: "text"
>> register: device_call_filtered
>>
>> # Debug of device_call_filtered. Output of matches and xmlstring keys 
>> shortened for readability.
>> ok: [some_switch] => {
>> "msg": [
>> {
>> "actions": {
>> "namespaces": {}, 
>> "state": "present", 
>> "xpath": "//vlan-id"
>> }, 
>> "changed": false, 
>> "count": 18, 
>> "failed": false, 
>> "matches": [
>> {
>> "vlan-id": "2141"
>> }, 
>> {
>> "vlan-id": "2056"
>> }
>> ], 
>> "msg": 18, 
>> "xmlstring": "\\n 
>> \\n \\n \\n some_vlan\\n 
>> 2141\\n \\n \\n "
>> }
>> ]
>> }
>>
>>   - name: "Create list of configured VLANs per Device."
>> set_fact:   
>>   device_list: "{{ device_call_filtered.matches | 
>> map(attribute='vlan-id') | list }}"
>> delegate_facts: true
>> 
>> # Debug of device_list. Output shortened for readability.
>> ok: [some_switch] => {
>> "msg": [
>> [
>> "2141", 
>> "2056"
>> ]
>> ]
>> }
>>
>>   - name: "Get difference."
>> set_fact:
>>   difference_list: "{{ cmdb_list | difference(device_list) }}"
>>   
>> ^ So that's not going to work in this state.
>>
>>

-- 
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/3eb306e4-a3b8-404d-9835-e2b7b278e190%40googlegroups.com.


[ansible-project] Re: Difficulty differencing list with integers vs list with strings.

2019-08-15 Thread Zolvaring
Would something like this syntax help?


set_fact:
  difference_list: >-
{{ numbers_as_integers |
difference(numbers_as_strings |
map(attribute='whatever_attribute_you_may_need') |
map('int') |
list }}

^ What that should do for the list of numbers as strings, is filter dicts 
into a pure list based on attribute (not clear if you need this or not, if 
you have a pure list of integers as strings you can remove that part 
obviously), the second map will apply the int filter to all members of your 
list, and then finally make it iterable with list. I was only able to test 
this briefly but it seemed to work for me if I understand what you're 
trying to do.

On Thursday, August 15, 2019 at 3:09:03 PM UTC-7, Auralan wrote:
>
> Hi everyone,
>
> I've been struggling to get the difference between 2 lists in Ansible. 
> List 1 contains numbers as integers. List 2 contains numbers as strings.
> These obviously cannot be filtered with difference(). 
>
> Does anyone know a workaround? Or a point where I can make a change in my 
> parsing to remediate this difference?
> We are using Ansible 2.7.10. Upgrading is an option if needed. My setup 
> is below.  Thank you for your time!
>
>
>
> List 1 comes from parsing a JSON document.
>
>
>   - name: "Create list from JSON source."
> set_fact:
>   cmdb_list: "{{ cmdb_call.json.results | map(attribute='vid') | list 
> }}"
>
> # Debug of cmdb_list. Output shortened for readability.
> ok: [localhost] => {
> "msg": [
> [
> 2141, 
> 2142, 
> 2143
> ]
> ]
> }
>
>
>
> List 2 comes from parsing a XML document in 2 steps.
>
>   - name: "Create list from XML source. Step 1."
> xml:
>   xmlstring: "{{ device_call.ansible_facts.ansible_net_config }}"
>   xpath: //vlan-id
>   content: "text"
> register: device_call_filtered
>
> # Debug of device_call_filtered. Output of matches and xmlstring keys 
> shortened for readability.
> ok: [some_switch] => {
> "msg": [
> {
> "actions": {
> "namespaces": {}, 
> "state": "present", 
> "xpath": "//vlan-id"
> }, 
> "changed": false, 
> "count": 18, 
> "failed": false, 
> "matches": [
> {
> "vlan-id": "2141"
> }, 
> {
> "vlan-id": "2056"
> }
> ], 
> "msg": 18, 
> "xmlstring": "\\n 
> \\n \\n \\n some_vlan\\n 
> 2141\\n \\n \\n "
> }
> ]
> }
>
>   - name: "Create list of configured VLANs per Device."
> set_fact:   
>   device_list: "{{ device_call_filtered.matches | 
> map(attribute='vlan-id') | list }}"
> delegate_facts: true
> 
> # Debug of device_list. Output shortened for readability.
> ok: [some_switch] => {
> "msg": [
> [
> "2141", 
> "2056"
> ]
> ]
> }
>
>   - name: "Get difference."
> set_fact:
>   difference_list: "{{ cmdb_list | difference(device_list) }}"
>   
> ^ So that's not going to work in this state.
>
>

-- 
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/d6154dbf-e628-4547-a968-0f69bff72fbd%40googlegroups.com.


[ansible-project] Re: Confused newbie - ERROR! the field 'hosts' is required but was not set

2019-08-15 Thread Zolvaring
In regards to your second question (sorry I missed it), the module looks 
okay except you need to indent the module out one more indentation space:
- name:
  hosts:
  tasks:
- get_url:
url:

The only other thing that looks immediately wrong to me is your destination 
parameter -- I don't think "$PWD" will work in this case ansible won't 
resolve the command as you execute it. If you are trying to put it in the 
current working directory of the ansible executor you can try "./" or 
specify the directory with set_fact or a variable.
  

On Thursday, August 15, 2019 at 6:23:05 PM UTC-7, GM wrote:
>
> Hi there - first I will post my response from when I run my playbook:
>
> ansible-playbook -vv glen.yml
>
> ansible-playbook 2.5.2
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = 
> [u'/home/gmillard/.ansible/plugins/modules', 
> u'/usr/share/ansible/plugins/modules']
>   ansible python module location = /usr/lib/python2.7/site-packages/ansible
>   executable location = /usr/bin/ansible-playbook
>   python version = 2.7.15 (default, May  9 2018, 11:32:33) [GCC 7.3.1 
> 20180130 (Red Hat 7.3.1-2)]
> Using /etc/ansible/ansible.cfg as config file
>
> PLAYBOOK: glen.yml 
> ***
> 2 plays in glen.yml
>
> PLAY [all] 
> ***
>
> TASK [Gathering Facts] 
> ***
> task path: /home/gmillard/myplatform/OtherStuff/glen.yml:2
> ok: [fedoracontrol]
> META: ran handlers
> META: ran handlers
> META: ran handlers
> ERROR! the field 'hosts' is required but was not set
>
> Now, I'll post the playbook itself:
> ---
> - hosts: all
> - name: "download artifactory"
>   tasks:
>   - get_url:
>   url: 
> http://10.10.10.170:8081/artifactory/generic-local-repo/FilesArchive.tar.gz
>   headers:  
> "X-JFrog-Art-Api:x"
>   dest: $PWD
>   mode: 0644
>
> Two things:
> 1. Why am I getting the *ERROR! the field 'hosts' is required but was not 
> set - * I'm thinking that my formatting/indentations are incorrect.
> 2. I'm attempting to grab an artifact from JFrog Artifactory - using the 
> get_url module - am I using it correctly?  
>
> Any and all help is appreciated. Thanks in advance.
>
> 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0d54478a-72b5-4b6c-8e8e-1d526f8c1c0b%40googlegroups.com.


[ansible-project] Re: Confused newbie - ERROR! the field 'hosts' is required but was not set

2019-08-15 Thread Zolvaring
The problem in this case is just the yaml syntax. "-" denotes the start of 
a new item, typically in a list, so when you write:

- hosts
- name

You are actually writing two separate objects, when what you want is:

- name: "download artifactory"
  hosts: all


On Thursday, August 15, 2019 at 6:23:05 PM UTC-7, GM wrote:
>
> Hi there - first I will post my response from when I run my playbook:
>
> ansible-playbook -vv glen.yml
>
> ansible-playbook 2.5.2
>   config file = /etc/ansible/ansible.cfg
>   configured module search path = 
> [u'/home/gmillard/.ansible/plugins/modules', 
> u'/usr/share/ansible/plugins/modules']
>   ansible python module location = /usr/lib/python2.7/site-packages/ansible
>   executable location = /usr/bin/ansible-playbook
>   python version = 2.7.15 (default, May  9 2018, 11:32:33) [GCC 7.3.1 
> 20180130 (Red Hat 7.3.1-2)]
> Using /etc/ansible/ansible.cfg as config file
>
> PLAYBOOK: glen.yml 
> ***
> 2 plays in glen.yml
>
> PLAY [all] 
> ***
>
> TASK [Gathering Facts] 
> ***
> task path: /home/gmillard/myplatform/OtherStuff/glen.yml:2
> ok: [fedoracontrol]
> META: ran handlers
> META: ran handlers
> META: ran handlers
> ERROR! the field 'hosts' is required but was not set
>
> Now, I'll post the playbook itself:
> ---
> - hosts: all
> - name: "download artifactory"
>   tasks:
>   - get_url:
>   url: 
> http://10.10.10.170:8081/artifactory/generic-local-repo/FilesArchive.tar.gz
>   headers:  
> "X-JFrog-Art-Api:x"
>   dest: $PWD
>   mode: 0644
>
> Two things:
> 1. Why am I getting the *ERROR! the field 'hosts' is required but was not 
> set - * I'm thinking that my formatting/indentations are incorrect.
> 2. I'm attempting to grab an artifact from JFrog Artifactory - using the 
> get_url module - am I using it correctly?  
>
> Any and all help is appreciated. Thanks in advance.
>
> 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a520f148-78a3-49c6-a125-67571a904bfe%40googlegroups.com.


[ansible-project] Re: "censored": "the output has been hidden due to the fact that 'no_log: true' was specified for this result

2019-08-14 Thread Zolvaring


On Monday, March 12, 2018 at 8:36:46 PM UTC-7, Camilo Vieira wrote:
>
> Hi, 
>
> This is my environment:
>
> # lsb_release -a
> No LSB modules are available.
> Distributor ID: Ubuntu
> Description:Ubuntu 16.04.2 LTS
> Release:16.04
> Codename:   xenial
>
> # python --version
> Python 2.7.12
>
> # python3 --version
> Python 3.5.2
>
> # ansible --version
> ansible 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/dist-packages/ansible
>   executable location = /usr/bin/ansible
>   python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 
> 20160609]
>
> # molecule --version
> molecule, version 2.10.1
>
>
> I have receiving the following error:
>
> # molecule test
> --> Test matrix
>
> └── default
> ├── lint
> ├── destroy
> ├── dependency
> ├── syntax
> ├── create
> ├── prepare
> ├── converge
> ├── idempotence
> ├── side_effect
> ├── verify
> └── destroy
>
> --> Scenario: 'default'
> --> Action: 'lint'
> --> Executing Yamllint on files found in /vagrant/roles/test/...
> Lint completed successfully.
> --> Executing Flake8 on files found in 
> /vagrant/roles/test/molecule/default/tests/...
> Lint completed successfully.
> --> Executing Ansible Lint on 
> /vagrant/roles/test/molecule/default/playbook.yml...
> Lint completed successfully.
> --> Scenario: 'default'
> --> Action: 'destroy'
>
> PLAY [Destroy] 
> *
>
> TASK [Destroy molecule instance(s)] 
> 
> changed: [localhost] => (item=None)
>
> TASK [Wait for instance(s) deletion to complete] 
> ***
> failed: [localhost] (item=None) => {"attempts": 1, "censored": "the 
> output has been hidden due to the fact that 'no_log: true' was specified 
> for this result", "changed": false}
>
> PLAY RECAP 
> *
> localhost  : ok=1changed=1unreachable=0
> failed=1
>
>
> ERROR:
> An error occured during the test sequence.  Cleaning up.
> --> Scenario: 'default'
> --> Action: 'destroy'
>
> PLAY [Destroy] 
> *
>
> TASK [Destroy molecule instance(s)] 
> 
> changed: [localhost] => (item=None)
>
> TASK [Wait for instance(s) deletion to complete] 
> ***
> failed: [localhost] (item=None) => {"attempts": 1, "censored": "the 
> output has been hidden due to the fact that 'no_log: true' was specified 
> for this result", "changed": false}
>
> PLAY RECAP 
> *
> localhost  : ok=1changed=1unreachable=0
> failed=1
>
>
> ERROR:
>
> Somebody could help me to fix it?
>
> Thanks
>
>

It looks like you're using molecule with the Ansible provisioner. By 
default, the Ansible provisioner in Molecule does hides certain logs, but 
if you go to your `molecule.yml` file (in 
`/molecule//molecule.yml`, in your example the 
name is 'default') you can configure it as such:
```
provisioner:
  name: ansible
  log: true
```

After that all log output related to creation/destruction should be visible 
in the console.

-- 
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/b5f16d3a-5b9a-44f9-b588-cc77959e60cb%40googlegroups.com.


[ansible-project] Re: Check attempt count in runtime

2019-08-06 Thread Zolvaring
So I thought of a workaround using nested loops shortly after posting this. 
I'm going to leave this open because I think that being aware of retries in 
runtime should be possible, but I wanted to post the solution for anyone 
else stuck:

---
# file: tasks/main.yml

- name: Include API configuration items
  include_tasks: configure_api_item.yml
  loop: "{{ my_api_items }}"
  loop_control:
loop_var:  __api_item


---
# file: tasks/configure_api_item.yml

- name: Configure API item
  uri:
url: 
method: "{{ __method }}"
headers:
  - 
  - 
body: 
  loop:
- POST
- PUT
  register: __results
  changed_when: 
- __results.status is defined
- __results.status == 201
  failed_when:
- __results.status is defined
- __results.status != 200
- __results.status != 201
- __results.status != 409

-- 
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/ef725d5a-0343-4252-9243-2c8bd1804ea8%40googlegroups.com.


[ansible-project] Check attempt count in runtime

2019-08-06 Thread Zolvaring
I'm trying to work with an API in an idempotent and DRY fashion and cannot 
find a way to do this for the life of me. What I want to do is hit an 
endpoint with POST, detect if the response indicates the resource already 
exists and, if so, hit it with a PUT on retry in order to make sure it's 
set properly.

What I have is this <> just for removing needless info:
- name: Configure my thing
  uri:
url: https://{{ ansible_hostname }}:
method: >-
  {% if results is defined and results.attempts is defined and 
results.attempts >= 1 -%}
PUT
  {%- else -%}
POST
  {% endif %}
headers:
  
body: 
  loop: 
  register: results
  retries: 1
  until: item is changed
  changed_when: item.status == 201
  failed_when:
- item.status != 200
- item.status != 201
- item.status != 409


The condition is never triggered when I run the task and both retries end 
up with POST. I tried the simpler method jinja2 of "{% if results is not 
defined %}POST{% else %}PUT{% endif %} but this never triggers as well, and 
it seems like even on attempt 2 I cannot access `results` to actually 
trigger any useful modifications to task parameters.

I'd really appreciate any help if anyone knows what can sort me out here. I 
realize I can break this up into two or more tasks and have versions that 
do that but I am looking for the best solution here and to me that means 
DRY and I'm trying to avoid having multiple tasks or blocks for each action.

-- 
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/23cf1a47-7959-4020-9a2a-383e8ff3f0be%40googlegroups.com.