With apt
both commands below are equivalent to one another in terms of the end result:
apt install libreoffice-writer libreoffice-calc libreoffice-impress
apt install libreoffice-{writer,calc,impress}
The second one has the ability to save a lot of typing especially if the prefix is very long.
However, attempting to transfer this to Ansible
---
- hosts: employee
become: true
vars:
supp_dist:
- "Ubuntu"
- "Debian"
supp_dist_ver:
- "24"
- "12"
tasks:
- name: update client
apt:
update_cache: yes
when: >
ansible_distribution == "Ubuntu" and
ansible_distribution_major_version in supp_dist_ver
- name: install desktop for client
apt:
name:
- xfce4
- xfce4-goodies
- libreoffice-gtk4
- libreoffice-{writer,calc,impress,draw,formulas}
- libreoffice-l10n-{de,eu,en-gb,uk}
leads to the error
fatal: [test.vms.home.com]: FAILED! => {"changed": false, "msg": "No package matching 'libreoffice-{writer,calc,impress' is available"}
I am a beginner Ansible user (version 2.14.3). I checked the documentation on the apt module but there is no mention of curly braces.
Q: "Is it possible to use curly braces to list multiple packages that have the same prefix?"
As far as I understand, no. This is because Brace Expansion is provided by the shell, whereby according the documentation apt
- Parameter: name
Name wildcards (fnmatch) like
apt*
and version wildcards likefoo=1.0*
are also supported.
are provided by the module.