Browse the Repo

file-type-icon.circleci
file-type-icon_ci
file-type-icon_docs
file-type-iconcodegen
file-type-iconexamples
file-type-iconmodules
file-type-icon_deprecated
file-type-iconaccount-baseline-app
file-type-iconaccount-baseline-root
file-type-iconaccount-baseline-security
file-type-iconauto-update
file-type-iconinstall-scripts
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconinstall.sh
file-type-iconaws-auth
file-type-iconaws-config-multi-region
file-type-iconaws-config
file-type-iconaws-organizations-config-rules
file-type-iconaws-organizations
file-type-iconcloudtrail
file-type-iconcross-account-iam-roles
file-type-iconcustom-iam-entity
file-type-iconfail2ban
file-type-iconguardduty-multi-region
file-type-iconguardduty
file-type-iconiam-groups
file-type-iconiam-policies
file-type-iconiam-user-password-policy
file-type-iconiam-users
file-type-iconip-lockdown
file-type-iconkms-master-key-multi-region
file-type-iconkms-master-key
file-type-iconntp
file-type-iconos-hardening
file-type-iconsaml-iam-roles
file-type-iconssh-grunt-selinux-policy
file-type-iconssh-grunt
file-type-iconssh-iam
file-type-iconssm-healthchecks-iam-permissions
file-type-icontls-cert-private
file-type-icontest
file-type-icon.editorconfig
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.adoc

Browse the Repo

file-type-icon.circleci
file-type-icon_ci
file-type-icon_docs
file-type-iconcodegen
file-type-iconexamples
file-type-iconmodules
file-type-icon_deprecated
file-type-iconaccount-baseline-app
file-type-iconaccount-baseline-root
file-type-iconaccount-baseline-security
file-type-iconauto-update
file-type-iconinstall-scripts
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-iconinstall.sh
file-type-iconaws-auth
file-type-iconaws-config-multi-region
file-type-iconaws-config
file-type-iconaws-organizations-config-rules
file-type-iconaws-organizations
file-type-iconcloudtrail
file-type-iconcross-account-iam-roles
file-type-iconcustom-iam-entity
file-type-iconfail2ban
file-type-iconguardduty-multi-region
file-type-iconguardduty
file-type-iconiam-groups
file-type-iconiam-policies
file-type-iconiam-user-password-policy
file-type-iconiam-users
file-type-iconip-lockdown
file-type-iconkms-master-key-multi-region
file-type-iconkms-master-key
file-type-iconntp
file-type-iconos-hardening
file-type-iconsaml-iam-roles
file-type-iconssh-grunt-selinux-policy
file-type-iconssh-grunt
file-type-iconssh-iam
file-type-iconssm-healthchecks-iam-permissions
file-type-icontls-cert-private
file-type-icontest
file-type-icon.editorconfig
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME.adoc
auto-update

auto-update

Configure a Linux server to automatically install critical security updates.

Code Preview

Preview the Code

mobile file icon

core-concepts.md

down

Auto Update Core Concepts

Installation

To use this module, you need to:

  1. Install bash-commons on your servers.
  2. Install and run the configure-auto-update script on your servers.

The best way to do that is to use the Gruntwork Installer in a Packer template (make sure to replace <BASH_COMMONS_VERSION> and <MODULE_SECURITY_VERSION> below with the latest versions from the bash-commons releases page and module-security releases page, respectively):

gruntwork-install --module-name bash-commons --tag <BASH_COMMONS_VERSION> --repo https://github.com/gruntwork-io/bash-commons
gruntwork-install --module-name auto-update --tag <MODULE_SECURITY_VERSION> --repo https://github.com/gruntwork-io/module-security

Ubuntu support

On Ubuntu, we use unattended-upgrades to automatically install updates. A cron job runs unattended-upgrades once per day. Our default configuration is as follows:

  • Run unattended-upgrades daily via a cron job, with a random delay between 0 and 30 minutes (configured via the APT::Periodic::RandomSleep) so all of your servers don't update at the exact same time.
  • On each run of unattended-upgrades, update the package list, download updates, and install updates. Once per week, clean up the local download archive.
  • Only use updates from the Debian Security Updates channel, which should contain security updates prepared by the Debian Security Team and/or by package maintainers. Check out security.debian.org for what the types of updates are included on this channel. If you use custom APT repos, you may need to add other origins or channels (see Repositories for Stable Users) using a custom configuration file, as specified below.
  • Log all unattended-upgrades output /var/log/unattended-upgrades.

You can find most of this configuration under install-scripts/unattended_upgrades_config.txt. If you wish to specify a custom configuration, you can use the --unattended-upgrades-config option when installing the auto-update module (if you're using gruntwork-install, you'll need to use the --module-param option, such as gruntwork-install --module auto-update --module-param unattended-upgrades-config=/foo/bar/my_unattended_upgrades_config).

Amazon Linux and CentOS Support

On Amazon Linux and CentOS, we use yum-cron and yum-security to automatically install updates. Note that Amazon Linux automatically installs security updates at launch time, but if you don't redeploy your servers very often (e.g. the EC2 Instances in an ECS Cluster), your server may go a long time without security updates, so we use yum-cron to update the server more often. Our default configuration is as follows:

  • Run yum-cron daily via a cron job, with a random delay between 0 and 30 minutes (configured via the random_sleep variable) so all of your servers don't update at the exact same time.
  • On each run of yum-cron, update the package list, download updates, and install updates.
  • On each run of yum-cron, run yum --security upgrade. This will install all updates marked as security updates in your yum repos. By default, Amazon Linux comes with the amzn-main and amzn-updates yum repos and you can find a list of Amazon security bulletins here.
  • Log all yum-cron output to /var/log/cron and /var/log/yum.log

You can find most of this configuration under install-scripts/yum_cron_config.txt. If you wish to specify a custom configuration, you can use the --yum-cron-config option when installing the auto-update module (if you're using gruntwork-install, you'll need to use the --module-param option, such as gruntwork-install --module auto-update --module-param yum-cron-config=/foo/bar/my_yum_cron_config).

Limitations

  • This module only updates software installed on your servers using the default package manager (apt for Ubuntu, yum for Amazon Linux and CentOS). Any software you install through other means, such as downloading binaries through curl or using an alternate package manager (e.g. gem, npm, nix, etc) will NOT be updated.
  • The default configuration only installs security updates. Other types of bug fixes, even serious, but not-security sensitive ones, will NOT be installed automatically.
  • The default configuration of this module does NOT reboot your servers automatically. This helps avoid unexpected downtime, but it means that any security updates that require a reboot to work will require you to update your AMIs and redeploy them yourself.

TODO

  • Both unattended-upgrades and yum-cron support email notification after each update. We could enable this, possibly using Amazon SES to send the emails.

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?