I am installing packages from a variable, which works fine with yum; however, with apt I am having issues unless I change the format of the variable. Perhaps apt still allows you to use “with_items” unlike yum (which complains that the loop is deprecated in favor of a variable)? I haven’t tested that last speculation yet.
With yum I can install the following:
`
packages: “dbus, krb5-workstation, sssd, sssd-client, oddjob, samba-common, samba-common-tools, chrony”
- name: ldap_users - Install required packages (RedHat-based)
yum:
name: “{{ packages }}”
state: present
skip_broken: yes
changed_when: false
ignore_errors: yes
when: ansible_os_family == “RedHat”
`
If I try something similar with apt, it always fails to install the packages (usually says it can’t find krb5-user).
Failing:
`
packages: “dbus, krb5-user, sssd, oddjob, samba-common, samba, chrony, libpam-sss, libnss-sss, libnss-ldap”
- name: ldap_users - Install required packages (Debian-based)
apt:
name: “{{ packages }}”
update_cache: yes
state: present
changed_when: false
ignore_errors: yes
when: ansible_os_family == “Debian”
`
However, if I change my variable to the following for Ubuntu, it works fine:
`
packages:
- dbus
- krb5-user
- sssd
- oddjob
- samba-common
- samba
- chrony
- libpam-sss
- libnss-sss
- libnss-ldap
`
Just wondering if someone can explain that to me?
For thouroughness, here is the error I get:
`
The full traceback is:
WARNING: The below traceback may not be related to the actual failure.
File “/tmp/ansible_apt_payload_wK2PGK/main.py”, line 345, in package_status
pkg = cache[pkgname]
File “/usr/lib/python2.7/dist-packages/apt/cache.py”, line 262, in getitem
raise KeyError(‘The cache has no package named %r’ % key)
fatal: [ansible-ub18]: FAILED! => {
“changed”: false,
“invocation”: {
“module_args”: {
“allow_unauthenticated”: false,
“autoclean”: false,
“autoremove”: false,
“cache_valid_time”: 1,
“deb”: null,
“default_release”: null,
“dpkg_options”: “force-confdef,force-confold”,
“force”: false,
“force_apt_get”: false,
“install_recommends”: null,
“name”: “dbus, krb5-user, sssd, oddjob, samba-common, samba, chrony, libpam-sss, libnss-sss, libnss-ldap”,
“only_upgrade”: false,
“package”: [
“dbus”,
" krb5-user",
" sssd",
" oddjob",
" samba-common",
" samba",
" chrony",
" libpam-sss",
" libnss-sss",
" libnss-ldap"
],
“purge”: false,
“state”: “present”,
“update_cache”: null,
“upgrade”: null
}
},
“msg”: “No package matching ’ krb5-user’ is available”
}
…ignoring
`