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
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
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
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:
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'
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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:
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
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
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
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
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
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
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
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
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
30 matches
Mail list logo