I am looking for the fact, which contains the following information:
$ dpkg --print-architecture
amd64
I can not find it:
$ ansible host -m setup | grep amd64
"BOOT_IMAGE": "/boot/vmlinuz-4.19.0-6-amd64",
"ansible_kernel": "4.19.0-6-amd64",
"BOOT_IMAGE": "/boot/vmlinuz-4.19.0-6-amd64",
Using ansible.builtin.shell is a bad idea. Because it will change the state everytime. I suggest to use mapping with ansible facts.
---
vars:
deb_architecture: {
"aarch64": "arm64",
"x86_64": "amd64"
}
tasks:
- name: Debug message
ansible.builtin.debug:
msg: "{{ [ansible_architecture] | map('extract', deb_architecture) | first }}"
# like example add docker repo
- name: Add Docker APT repository
ansible.builtin.apt_repository:
repo: deb [arch={{ [ansible_architecture] | map('extract', deb_architecture) | first }}] https://download.docker.com/{{ ansible_system | lower }}/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable
You can do (this works on everything):
ansible HOST -m setup -a 'filter=ansible_architecture'
Or (this only works on Debian):
- name: Get DEB architecture
shell: dpkg --print-architecture
register: deb_architecture
- name: Print DEB architecture
debug:
msg: "deb_architecture.stdout: {{ deb_architecture.stdout }}"
The returned value is:
https://en.wikipedia.org/wiki/X86-64
There might be different systems calling the same architecture using different names because of historical reasons:
https://en.wikipedia.org/wiki/X86-64#History
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With