I wish to check using if condition inside a jinja template where any of the
folders starting with the name "dump_" has any file starting with the name
bad
For for single folder the below jinja template works as suggested by an
expert on this forum.
{% if lookup('fileglob', playbook_dir +
On Fri, 6 Mar 2020 09:15:51 -0800 (PST)
Quentin Aveno wrote:
> - name: test
> vars:
> test1: "test1"
> test2:
> - "test21"
> - "test22"
> test3:
> - "{{ test1 }}"
> - "{{ test2 }}"
>
> debug:
> msg: "{% for tt in test3 %} {{ tt }} {% endfor %}"
>
As I mentioned in that issue the processes run from Ansible with the
highest privileges available to the user you can verify this by running
- win_command: whoami.exe /all
Here is what you should roughly see back
(ansible-py37) jborean:~/dev/ansible-tester$ ansible 2019 -m win_command -a
Hi,
I'm unable to get win_shell to run with elevated "run as admin" privileges.
I have the details posted below in this issue:
https://github.com/ansible/ansible/issues/68086
As stated, I tried to see if it could be a double hop issue by adding the
become logic but this did not work. The
Thank you. That’s what I needed.
Mike
> On Mar 2, 2020, at 19:07, Vladimir Botka wrote:
>
> On Mon, 2 Mar 2020 14:41:28 -0600
> Mike Eggleston wrote:
>
>> I will write a program that looks for network devices on its local network
>> and created a report of the findings. That’s easy. Using
Hi guys,
I got a question concerning list of lists and strings.
I have something like :
- name: test
vars:
test1: "test1"
test2:
- "test21"
- "test22"
test3:
- "{{ test1 }}"
- "{{ test2 }}"
debug:
msg: "{% for tt in test3 %} {{ tt }} {% endfor
Are you using `--limit` param for ansible-playbook?
Dne středa 4. března 2020 14:49:44 UTC+1 Vishal Bobade napsal(a):
>
>
> TASK [ansible-manage-lvm : manage_lvm | creating new LVM volume group(s)]
> **
> [0;31mfatal: [grafana]: FAILED! => {"msg": "'config_lv_name' is undefined"}
> [0m
>
Thanks for the note on the "Become" double hop snafu's, found another post
from a year or so ago where you helped someone else with resolving their
become issues and used that to muddle through it myself.
solution
- name: Create DFS links
win_shell: |
.
Hi Ansible helpers,
Could someone help on how to use the Ansible gcp_compute_snapshot module?
I created an Ansible playbook as bollow but ran into one error during the
snapshot on SUSE 12.3. The error was "fatal: [patchtest03]: FAILED! =>
{"changed": false, "msg": "argument source_disk is of
I have this working.
I've a role that configs the L3VPN, so I created two tasks within that
role. One loads the vars, and the other produces the router configuration.
roles/config_l3vpn/tasks/load.yml
---
- name: include vars
include_vars: ./host_vars/{{ inventory_hostname
On 3/6/20 3:05 PM, 'Brandon Daly' via Ansible Project wrote:
> I have a play that is creating yaml for each of my hosts and this is stored
> in './host_vars/{{ inventory_hostname
> }}/l3vpn.yml
>
> I then have a second play in which I wish to use this yaml.
>
> both are called from another
I have a play that is creating yaml for each of my hosts and this is stored
in './host_vars/{{ inventory_hostname }}/l3vpn.yml
I then have a second play in which I wish to use this yaml.
both are called from another playbook;
[ansible@ansi001 juniper]$ more live.all.pb.yam
---
-
On Thursday, March 5, 2020 at 8:48:12 PM UTC, Kai Stian Olstad wrote:
>
> On 05.03.2020 15:52, David Foley wrote:
> > Have the Following Playbook Which Returns the following
> >
> > ok: [localhost] => {
> > "mdb.json": [
>
> The [ is telling us that mdb.json is a list, the fist element
Why not use the uri module instead of fragile shell + curl ?
On Fri, 6 Mar 2020 at 13:47, Rakesh Parida
wrote:
> Hi,
>
> I have a task as follows:
>
> - hosts: nodes
> gather_facts: true
> tasks:
> - name: CurlCP Status
> shell: "curl -Is -m 1 http://localhost:9113/cp/healthcheck;
On Fri, 6 Mar 2020 04:46:58 -0800 (PST)
Rakesh Parida wrote:
> failed_when: "'200 OK' not in cp_status.stdout_lines"
Try
failed_when: cp_status.stdout_lines|
select('search', '200 OK')|
list|
length == 0
HTH,
-vlado
--
On 3/6/20 1:35 PM, Shifa Shaikh wrote:
> I know how to lookup a file using fileglob in Ansible but not sure how to
> inside a Jinja template.
>
Very simple:
{% if lookup('fileglob', '/home/racke/tmp/*.txt') %}
Regards
Racke
> On Fri, 6 Mar, 2020, 5:55 pm Stefan Hornburg (Racke),
Hi,
I have a task as follows:
- hosts: nodes
gather_facts: true
tasks:
- name: CurlCP Status
shell: "curl -Is -m 1 http://localhost:9113/cp/healthcheck;
register: cp_status
failed_when: "'200 OK' not in cp_status.stdout_lines"
It fails even if 200 Ok is in o/p. I want
On 3/5/20 6:31 PM, John wrote:
> I have a task that searches logs for specific errors in various logs (up to 7
> days worth of logs). When searching
> through just one log I never had an issue, but when searching through the 7
> logs (used a wildcard to accomplish this),
> sometimes Ansible
I know how to lookup a file using fileglob in Ansible but not sure how to
inside a Jinja template.
On Fri, 6 Mar, 2020, 5:55 pm Stefan Hornburg (Racke),
wrote:
> On 3/6/20 1:12 PM, Shifa Shaikh wrote:
> > @Stefan I wish to check if the file bad*.txt exists on the path. Based
> on the if
On 3/6/20 1:12 PM, Shifa Shaikh wrote:
> @Stefan I wish to check if the file bad*.txt exists on the path. Based on the
> if condition I wish to template different
> output.
I assume that you are checking for file names matching bad*.txt. In that case
you can use the fileglob lookup:
@Stefan I wish to check if the file bad*.txt exists on the path. Based on
the if condition I wish to template different output.
On Fri, 6 Mar, 2020, 5:34 pm Stefan Hornburg (Racke),
wrote:
> On 3/6/20 12:52 PM, Shifa Shaikh wrote:
> > @Stefan I tried you suggestion of not using the curly
On 3/6/20 12:52 PM, Shifa Shaikh wrote:
> @Stefan I tried you suggestion of not using the curly braces and it helped
> resolve the error. But now i get a new error.
>
> |
> {%ifplaybook_dir +'/'+item +'/'+'bad*.txt'|exists %}
> |
There is no filter named 'exists'. Please explain what you want
@Stefan I tried you suggestion of not using the curly braces and it helped
resolve the error. But now i get a new error.
{% if playbook_dir + '/' + item + '/' + 'bad*.txt' | exists %}
TASK [Create the Jinja2 based template]
@Stefan sorry but I could not understand your statement.
Are you asking me to move the if statement out of the jinja template ?
Below is the complete jinja template with the if statement that errors. I'm
able to populate all the values correctly and the playbook works fine when
the if
Thank you for your answer. So basically I need to run 2 tasks *BUT*
If I have a list of folders that needs to be created and i will use
with_items - As I know, the first task will run on all folders and the MSG
task will only verify the register of the last folder.
Basically what I'm
On 3/6/20 11:52 AM, Shifa Shaikh wrote:
> Vladimir Hi,
>
> I tried
>
> |
> {%if{{playbook_dir }}/{{item }}/bad*.txt |exists %}
>
Don't use the curly braces inside the {%if ... } condition:
{% if playbook_dir + '/' + item + '/' + 'bad*.txt' | exists %}
Regards
Racke
>
> {{item
On 3/6/20 12:02 PM, Jean-Yves LENHOF wrote:
> Hi,
>
> Your error is about a for loop, but your template included in your email
> doesn't have this loop.
The loop could be applied to the task, in that case you can use {{ item }} in
the template on its own.
Regards
Racke
>
> Looks
Jean hi,
I incorporated the if statement from my previous post in my original Jinja
template after the second 'for loop' in my original post.
Once the if condition is removed the error does not show anymore.
On Fri, 6 Mar, 2020, 4:33 pm Jean-Yves LENHOF,
wrote:
> Hi,
>
> Your error is about a
If I remove the of statement the error goes away.
I can confirm i'm using the same Jinja template as the output error shared.
On Fri, 6 Mar, 2020, 4:33 pm Jean-Yves LENHOF,
wrote:
> Hi,
>
> Your error is about a for loop, but your template included in your email
> doesn't have this loop.
>
>
Hi,
Your error is about a for loop, but your template included in your email
doesn't have this loop.
Looks like you didn't give us the good one
Regards,
JYL
Le 06/03/2020 à 11:52, Shifa Shaikh a écrit :
Vladimir Hi,
I tried
|
{%if{{playbook_dir }}/{{item }}/bad*.txt |exists %}
{{item
Vladimir Hi,
I tried
{% if {{ playbook_dir }}/{{ item }}/bad*.txt | exists %}
{{ item }}
{% else %}
{{ item }}
{% endif %}
But I get this error:
TASK [Create the Jinja2 based template]
On Fri, 6 Mar 2020 01:59:00 -0800 (PST)
Shifa Shaikh wrote:
> How do i put the if /else condition in the jinja template ?
See "if"
https://jinja.palletsprojects.com/en/2.11.x/templates/#if
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
Here is my variable file
layers:
- name: APP
things:
- cactus
- lotus
- jasmine
- rose
- name: WAS
things:
- mango
- apple
Below is my jinja template file:
{% for layer in layers %}
{% for item in layer.things %}
{{
Hi,
Did you try a callback that satisfy you ?
https://docs.ansible.com/ansible/latest/plugins/callback.html
If not you should probably have to create yours...
Ansible is not the most obvious tool to create some reports... What did
you want to achieve ? If you want a proper report, perhaps
Thank you @Stefan,
That solves the issue !!
On Friday, March 6, 2020 at 2:32:07 PM UTC+5:30, Stefan Hornburg (Racke)
wrote:
>
> On 3/6/20 9:04 AM, Shifa Shaikh wrote:
> > I have a variable files like below:
> >
> > |
> > layers:
> > -name:APP
> > things:
> > -cactus
On 3/6/20 9:04 AM, Shifa Shaikh wrote:
> I have a variable files like below:
>
> |
> layers:
> -name:APP
> things:
> -cactus
> -lotus
> -jasmine
> -rose
> bgcolor:
> -sky blue
>
>
> -name:WAS
> things:
> -mango
>
Hi
You can find all about Jinja filters here
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html
But you can convert a list to a string using
{{ list | join(" ") }}
This will add a space between each element. I am not sure if that is what
you need.
On Fri, 6 Mar 2020
I have a variable files like below:
layers:
- name: APP
things:
- cactus
- lotus
- jasmine
- rose
bgcolor:
- sky blue
- name: WAS
things:
- mango
- apple
bgcolor:
- yellow
Below is my jinja
38 matches
Mail list logo