[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

[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 configurat

[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 > Pyt

[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:

[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'

[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

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

2019-08-15 Thread Zolvaring
ursday, 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_attrib

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

[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

[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_ar

[ansible-project] how to use Ansible meta module to halt playbook execution upon task Failure.

2019-08-15 Thread Zolvaring
If you want to use meta it's simple but will not mark the play as failed, as far as I know there's no explicit way to do that with meta: - name: abort if string was found meta: end_play when: command is failed It might be better to try the fail module since it will return the failed state

[ansible-project] Re: Erroneous playbook failure

2019-08-15 Thread Zolvaring
I don't know much about aide but that output appears to just show you what is being changed, is it possible aide simply uses rc 7 to denote that? If you don't believe the task is actually failing, try adding a param go the aide update task: register: aide_update failed_when: - aide_update.rc

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 Artfacto

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 questio

[ansible-project] Re: execute one task of a playbook locally and the rest on the remote hosts?

2019-08-20 Thread Zolvaring
I think what you're looking for is the 'delegate_to' task parameter. If you wanted the local action to only run once you can combine this with the 'run_once' task parameter -- for your example - name: bring file locally command: scp "{{qahost}}":"{{remotepath}}" "{{localpath}}" delega

[ansible-project] Re: Some user of ansible_user

2019-08-20 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_fact

[ansible-project] Re: Some user of ansible_user

2019-08-20 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 mess

[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_H

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

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

[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:

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 detec

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

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

[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://githu

[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

[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 whenev

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 th

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

2019-09-06 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

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