* Add support for autoupdates only Debian-based systems are supported for now (through unattended-upgrades package) * Fix test on system.autoupdates.pkgstags/2017.4
repo: 'custom-repo' | repo: 'custom-repo' | ||||
verify: false | verify: false | ||||
Linux with autoupdates (automatically install security package updates) | |||||
.. code-block:: yaml | |||||
linux: | |||||
system: | |||||
... | |||||
autoupdates: | |||||
enabled: true | |||||
mail: root@localhost | |||||
mail_only_on_error: true | |||||
remove_unused_dependencies: false | |||||
automatic_reboot: true | |||||
automatic_reboot_time: "02:00" | |||||
Linux with cron jobs | Linux with cron jobs | ||||
.. code-block:: yaml | .. code-block:: yaml |
{%- set autoupdates = salt['pillar.get']('linux:system:autoupdates') %} | |||||
{%- if autoupdates.enabled %} | |||||
APT::Periodic::Enable "1"; | |||||
APT::Periodic::Update-Package-Lists "1"; | |||||
APT::Periodic::Unattended-Upgrade "1"; | |||||
{%- else %} | |||||
APT::Periodic::Unattended-Upgrade "0"; | |||||
{%- endif %} | |||||
{%- if autoupdates.mail is defined %} | |||||
Unattended-Upgrade::Mail "{{ autoupdates.mail }}"; | |||||
{%- endif %} | |||||
{%- if autoupdates.mail_only_on_error is defined %} | |||||
Unattended-Upgrade::MailOnlyOnError "{{ "true" if autoupdates.mail_only_on_error else "false"}}"; | |||||
{%- endif %} | |||||
{%- if autoupdates.remove_unused_dependencies is defined %} | |||||
Unattended-Upgrade::Remove-Unused-Dependencies "{{ "true" if autoupdates.remove_unused_dependencies else "false"}}"; | |||||
{%- endif %} | |||||
{%- if autoupdates.automatic_reboot is defined %} | |||||
Unattended-Upgrade::Automatic-Reboot "{{ "true" if autoupdates.automatic_reboot else "false"}}"; | |||||
{%- endif %} | |||||
{%- if autoupdates.automatic_reboot_time is defined %} | |||||
Unattended-Upgrade::Automatic-Reboot-Time "{{ autoupdates.automatic_reboot_time }}"; | |||||
{%- endif %} |
'motd': {}, | 'motd': {}, | ||||
'repo': {}, | 'repo': {}, | ||||
'package': {}, | 'package': {}, | ||||
'autoupdates': { | |||||
'enabled': False, | |||||
'pkgs': [] | |||||
}, | |||||
'selinux': 'permissive', | 'selinux': 'permissive', | ||||
'ca_certs_dir': '/usr/local/share/ca-certificates', | 'ca_certs_dir': '/usr/local/share/ca-certificates', | ||||
'doc_validity_pkgs': ['python-yaml'], | 'doc_validity_pkgs': ['python-yaml'], | ||||
'motd': {}, | 'motd': {}, | ||||
'repo': {}, | 'repo': {}, | ||||
'package': {}, | 'package': {}, | ||||
'autoupdates': { | |||||
'enabled': False, | |||||
'pkgs': ['unattended-upgrades'] | |||||
}, | |||||
'selinux': 'permissive', | 'selinux': 'permissive', | ||||
'ca_certs_dir': '/usr/local/share/ca-certificates', | 'ca_certs_dir': '/usr/local/share/ca-certificates', | ||||
'doc_validity_pkgs': ['python-yaml'], | 'doc_validity_pkgs': ['python-yaml'], | ||||
'motd': {}, | 'motd': {}, | ||||
'repo': {}, | 'repo': {}, | ||||
'package': {}, | 'package': {}, | ||||
'autoupdates': { | |||||
'enabled': False, | |||||
'pkgs': [] | |||||
}, | |||||
'selinux': 'permissive', | 'selinux': 'permissive', | ||||
'ca_certs_dir': '/usr/local/share/ca-certificates', | 'ca_certs_dir': '/usr/local/share/ca-certificates', | ||||
'doc_validity_pkgs': ['PyYAML'], | 'doc_validity_pkgs': ['PyYAML'], |
{%- from "linux/map.jinja" import system with context %} | |||||
{%- if system.enabled %} | |||||
{%- if system.autoupdates is defined %} | |||||
{%- if system.autoupdates.pkgs %} | |||||
linux_autoupdates_packages: | |||||
pkg.installed: | |||||
- pkgs: {{ system.autoupdates.pkgs }} | |||||
{%- endif %} | |||||
{%- if grains.os_family == 'Debian' %} | |||||
/etc/apt/apt.conf.d/90autoupdates: | |||||
file.managed: | |||||
- source: salt://linux/files/90autoupdates | |||||
- template: jinja | |||||
- user: root | |||||
- group: root | |||||
- mode: 644 | |||||
{%- endif %} | |||||
{%- endif %} | |||||
{%- endif %} |
{%- if system.pkgs|length > 0 %} | {%- if system.pkgs|length > 0 %} | ||||
- linux.system.package | - linux.system.package | ||||
{%- endif %} | {%- endif %} | ||||
{%- if system.autoupdates is defined %} | |||||
- linux.system.autoupdates | |||||
{%- endif %} | |||||
{%- if system.timezone is defined %} | {%- if system.timezone is defined %} | ||||
- linux.system.timezone | - linux.system.timezone | ||||
{%- endif %} | {%- endif %} | ||||
{%- endif %} | {%- endif %} | ||||
{%- if system.config is defined %} | {%- if system.config is defined %} | ||||
- linux.system.config | - linux.system.config | ||||
{%- endif %} | |||||
{%- endif %} |