2019年11月27日水曜日

AnsibleでUbuntu18.04/Debian Buster/Raspbian Busterの自動アップデートを設定する

AnsibleでUbuntu18.04/Debian Buster/Raspbian Busterの自動アップデートを設定するには、以下のroleを使用します。

roles/automaticupdates/tasks/main.yml
---
- name: check if unattended-upgrades is installed.
  stat:
    path: "/etc/apt/apt.conf.d/50unattended-upgrades"
  register: chk_unattended_upgrades

- name: install unattended-upgrades
  apt: name=unattended-upgrades state=present update_cache=yes
  when: chk_unattended_upgrades.stat.exists == false
  become: true

- name: debconf to configure unattended-upgrades
  debconf: name="unattended-upgrades"
    question="unattended-upgrades/enable_auto_updates"
    value="true"
    vtype=boolean
  when: chk_unattended_upgrades.stat.exists == false
  become: true

- name: reconfigure unattended upgrades with dpkg
  shell: '/usr/sbin/dpkg-reconfigure --frontend noninteractive unattended-upgrades'
  when: chk_unattended_upgrades.stat.exists == false
  become: true

0 件のコメント:

コメントを投稿