6

Here we are trying to start auto updating packages in Ubuntu through Ansible playbook.

dpkg-reconfigure -plow unattended-upgrades

When we run this command manually, it shows the following prompt, and it starts updating packages :-

 Configuring unattended-upgrades

Applying updates on a frequent basis is an important part of keeping
systems secure. By default, updates need to be applied manually using
package management tools.
Alternatively, you can choose to have this system automatically download and install important updates.

Automatically download and install stable updates?

                  <Yes>                       <No> 

But running this command with Ansible it stopped at this step How we can skip this prompt while running this command with Ansible playbook.
Playbook code is following:- ansible-code for updating Ubuntu packages

karan
  • 61

1 Answers1

12

Here's how I set up unattended-upgrades using Ansible.

- name: echo "unattended-upgrades unattended-upgrades/enable_auto_updates boolean true" | sudo debconf-set-selections  - auto install security updates
  debconf: 
    name: unattended-upgrades 
    question: unattended-upgrades/enable_auto_updates 
    vtype: boolean 
    value: 'true'
  • name: apt install unattended-upgrades apt: name: unattended-upgrades

  • name: dpkg-reconfigure -f noninteractive unattended-upgrades command: cmd: dpkg-reconfigure -f noninteractive unattended-upgrades creates: /etc/apt/apt.conf.d/20auto-upgrades

Hrafn
  • 221
  • 1
  • 13