First, when I run your playbook I don't get an error; I just get no output from the debug
task:
"msg": ""
If you're looking for a list of lines that start with UUID
, you could do this:
- name: read content from a file
hosts: localhost
tasks:
- name: read a content
slurp:
src: /etc/fstab
register: output
- name: print
debug:
msg: >
{{
(output['content'] | b64decode).splitlines() |
select("match", "UUID")
}}
On my system, this produces:
ok: [localhost] => {
"msg": [
"UUID=2fbad834-42b2-48fd-868d-3eea12e144de / btrfs subvol=root00,compress=zstd:1 0 0",
"UUID=c72e509c-453a-4e62-8cea-23ad112765d3 /boot ext4 defaults 1 2",
"UUID=F3B3-4F58 /boot/efi vfat umask=0077,shortname=winnt 0 2",
"UUID=2fbad834-42b2-48fd-868d-3eea12e144de /home btrfs subvol=home00,compress=zstd:1 0 0",
]
}
If you wanted a line matching a specific uuid, you could do this:
- name: read content from a file
hosts: localhost
tasks:
- name: read a content
slurp:
src: /etc/fstab
register: output
- name: print
debug:
msg: >
{{
(output['content'] | b64decode).splitlines() |
select("match", "UUID=c72e509c-453a-4e62-8cea-23ad112765d3") |
first
}}
On my system this produces:
ok: [localhost] => {
"msg": "UUID=c72e509c-453a-4e62-8cea-23ad112765d3 /boot ext4 defaults 1 2\n"
}