I understand the problem. Thanks for restating it concisely.
Your template *is* creating /home/user1/mksysb_error_report.out, but not on
localhost.
It's creating it on each of the target hosts.
It's doing *that* because of the leading tabs I asked you about earlier.
There's one in front of your
Again, without the play including the "loop:" we have no idea what "item"
looks like.
When you get something like the error you quoted, where it's looking at an
object (a list object by that message) and you don't know how to reference
data contained within, just take off all the other bits and
I get what you're saying, but when I just debug print {{ item }} using the
results variable, I see all of the snapshots listed. If I add in the loop
and use {{ item[0] }}, I see the same information, and description is
included. But when I try to add description to the output, I am told that
OK, I think I have it:
- name: Show results
ansible.builtin.debug:
msg: "{{ item }}"
loop:
- "{{ result.results |
json_query('[*].ovirt_snapshots[*].description') }}"
This gives me what I want, to a point. I would like to print the VM name
too, and that is at re
OK, finally figured it out. Used with_nested and was able to print both
items:
- name: Show results
ansible.builtin.debug:
msg: "{{ item[0] }} - {{ item[1] }}"
with_nested:
- "{{ result.results | json_query('[*].item') }}"
- "{{ result.results |
json_quer
Hi,
When I try to split the output of uptime to capture the "load average from
the below line
$ uptime
18:37:01 up 5 days, 4:37, 2 users, load average: 0.02, 0.05, 0.00
using the below playbook
---
- name: uptime_collect22
hosts: localhost
gather_facts: no
tasks:
- name: regist
If we do an apt-mark hold grub first, we are left with the dilemma of how
to update grub without presenting a dialog. This is only happening on
Debian 11 boxes. We have tried using the :
environment:
DEBIAN_FRONTEND: noninteractive
option, but it is not working.
On Thursday, Februar
load_avg: "{{ up_out.stdout_lines[0].split()[7:] }}"
Just use [7:] to get from position 7 on in your list.
---
- name: test splitting text
hosts: localhost
become: false
gather_facts: false
vars:
text_to_split: "18:37:01 up 5 days, 4:37, 2 users, load average: 0.02,
Veera,
Be careful splitting uptime on white space because when a system is up less
than 24 hours, it will show
12:58:10 up 6:51, 0 users, load average: 1.08, 0.99, 1.05
which will have one less white space and your desired output will be position 6.
I would recommend splitting the output on
The core problem here is a grub / Debian issue rather than Ansible and it
looks like you've already tried a few places for help. (
https://unix.stackexchange.com/questions/735375/update-grub-on-debian-11-fails
and https://forums.debian.net/viewtopic.php?t=154015)
1, Is it ALL Debian 11 machines o
An even more elegant solution would be to use '[-3:]' to get the last three
items regardless of how many there are.
---
- name: test splitting text
hosts: localhost
become: false
gather_facts: false
vars:
text_to_split: "18:37:01 up 5 days, 4:37, 2 users, load average: 0.02,
0.05,
% cat split.yml
---
- name: test splitting text
hosts: localhost
become: false
gather_facts: false
vars:
text_to_split1: "18:37:01 up 5 days, 4:37, 2 users, load average: 0.02,
0.05, 0.00"
text_to_split2: "12:58:10 up 6:51, 0 users, load average: 1.08, 0.99,
1.05"
tasks:
If you want the commas removed you can do that too.
- "{{ text_to_split1.replace(',','').split()[-3:] }}"
- "{{ text_to_split2.replace(',','').split()[-3:] }}"
ok: [localhost] => {
"msg": [
[
"0.02",
"0.05",
"0.00"
],
Append 2 lines in /etc/sudoers
Hi I have 2 lines starting with User_Alias
How do i make sure both lines get appended
at the moment only the last line is being appended using this playbook
tasks:
- name: add someuser to end of line
lineinfile:
dest: /etc/sudoers
state: present
regexp: '^(
On Mon, Feb 27, 2023 at 2:30 PM Hamim Ismail wrote:
> Append 2 lines in /etc/sudoers
>
> Hi I have 2 lines starting with User_Alias
>
> How do i make sure both lines get appended
>
> at the moment only the last line is being appended using this playbook
>
You don't. You put that content in as a
Thanks a lot for the valuable input..
On Monday, February 27, 2023 at 11:30:52 PM UTC+5:30 Hearn, Stan J. wrote:
> Veera,
>
>
>
> Be careful splitting uptime on white space because when a system is up
> less than 24 hours, it will show
>
>
>
> 12:58:10 up 6:51, 0 users, load average: 1.0
Thanks Walter.. the options helped me a lot.
On Monday, February 27, 2023 at 11:49:05 PM UTC+5:30 Rowe, Walter P. (Fed)
wrote:
> If you want the commas removed you can do that too.
>
> - "{{ text_to_split1.replace(',','').split()[-3:] }}"
> - "{{ text_to_split2.replace(',','
On Mon, 27 Feb 2023 21:07:45 -0800 (PST)
Veera wrote:
> load_avg: "{{ up_out.stdout_lines[0].split()[7:] }}"
Given the registered variable *up_out*
- command: uptime
register: up_out
Use the filter community.general.jc to parse the stdout. The utility
*jc* "converts the output of many co
18 matches
Mail list logo