Skip to content

Commit

Permalink
Merge pull request #41 from mergermarket/update-awslinux-2023
Browse files Browse the repository at this point in the history
update for awslinux 2023
  • Loading branch information
marciogoda authored Oct 18, 2023
2 parents 09b5654 + c6b72ac commit b022fa8
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 69 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
# defaults file for update-notifications
# defaults file for update-notifications
35 changes: 7 additions & 28 deletions files/yum-cron-notify.conf → files/dnf-automatic.conf
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
[commands]
# What kind of update to use:
# default = yum upgrade
# security = yum --security upgrade
# security-severity:Critical = yum --sec-severity=Critical upgrade
# minimal = yum --bugfix update-minimal
# minimal-security = yum --security update-minimal
# minimal-security-severity:Critical = --sec-severity=Critical update-minimal
update_cmd = default

# Whether a message should emitted when updates are available.
update_messages = yes

upgrade_type = default
# Whether updates should be downloaded when they are available. Note
# that updates_messages must also be yes for updates to be downloaded.
download_updates = no
download_updates = false

# Whether updates should be applied when they are available. Note
# that both update_messages and download_updates must also be yes for
# the update to be applied
apply_updates = no
apply_updates = false

# Maximum amout of time to randomly sleep, in minutes. The program
# will sleep for a random amount of time between 0 and random_sleep
Expand All @@ -27,6 +17,8 @@ apply_updates = no
# random_sleep is 0 or negative, the program will run immediately.
random_sleep = 30

reboot = never


[emitters]
# Name to use for this system in messages that are emitted. If
Expand All @@ -40,10 +32,6 @@ system_name = None
# If emit_via is None or left blank, no messages will be sent.
emit_via = stdio

# The width, in characters, that messages that are emitted should be
# formatted to.
output_width = 80


[groups]
# List of groups to update
Expand All @@ -53,16 +41,7 @@ group_list = None
group_package_types = mandatory, default

[base]
# This section overrides yum.conf

# Use this to filter Yum core messages
# -4: critical
# -3: critical+errors
# -2: critical+errors+warnings (default)
debuglevel = -2
# This section overrides dnf.conf

# skip_broken = True
mdpolicy = group:main
debuglevel = 2

# Uncomment to auto-import new gpg keys (dangerous)
# assumeyes = True
2 changes: 1 addition & 1 deletion files/notify_updates
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if [ -z "${STATELESS_INSTANCE}" ]; then
echo 'STATELESS_INSTANCE should be set to 0 or 1' >&1
fi

updates="$(/usr/sbin/yum-cron /etc/yum/yum-cron-notify.conf)"
updates="$(/usr/sbin/dnf-automatic /etc/dnf/automatic.conf)"
if [[ -n "${updates}" ]]; then
/usr/local/bin/send_datadog_event.py "${updates}"
fi
2 changes: 1 addition & 1 deletion handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
# handlers file for update-notifications
# handlers file for update-notifications
15 changes: 6 additions & 9 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
galaxy_info:
role_name: update_notifications
namespace: mergermarket
author: Acuris
description: Installs files for sending software update notifications to Datadog
company: Acuris/Mergermarket
Expand All @@ -10,7 +11,7 @@ galaxy_info:

license: none

min_ansible_version: 2.1
min_ansible_version: "2.1"

# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
Expand All @@ -21,15 +22,15 @@ galaxy_info:
# this branch. If Travis integration is configured, only notifications for this
# branch will be accepted. Otherwise, in all cases, the repo's default branch
# (usually master) will be used.
#github_branch:
# github_branch:

#
# platforms is a list of platforms, and each platform has a name and a list of versions.
#
platforms:
- name: Amazon
versions:
- all
- name: Amazon
versions:
- all

galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
Expand All @@ -38,7 +39,3 @@ galaxy_info:
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
53 changes: 26 additions & 27 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,64 +1,63 @@
- name: yum dependencies
yum:
name: "{{ item }}"
with_items:
- yum-cron
- name: Dnf dependencies
ansible.builtin.dnf:
name: dnf-automatic

- name: remove yum-cron hourly
file:
- name: Remove yum-cron hourly
ansible.builtin.file:
state: absent
path: "/etc/cron.hourly/0yum-hourly.cron"

- name: remove yum-cron daily
file:
- name: Remove yum-cron daily
ansible.builtin.file:
state: absent
path: "/etc/cron.hourly/0yum-daily.cron"

- name: notify script
copy:
- name: Notify script
ansible.builtin.copy:
src: notify_updates
dest: /usr/local/bin/
mode: 0755
mode: "0755"

- name: config file
copy:
src: yum-cron-notify.conf
dest: /etc/yum/
mode: 0644
- name: Config file
ansible.builtin.copy:
src: dnf-automatic.conf
dest: /etc/dnf/automatic.conf
mode: "0644"

- name: send datadog event
copy:
- name: Send datadog event
ansible.builtin.copy:
src: send_datadog_event.py
dest: /usr/local/bin
mode: 0755
mode: "0755"

- name: notify cron
cron:
- name: Notify cron
ansible.builtin.cron:
name: notify_updates
cron_file: notify_updates
user: root
minute: 0
minute: '0'
job: "/usr/local/bin/notify_updates &>> /var/log/notify_updates.log"

- name: Jenkins job name for API
cronvar:
community.general.cronvar:
name: JENKINS_JOB_NAME
value: "%JENKINS_JOB_NAME_TEMPLATE%"
cron_file: notify_updates

- name: Datadog API token
cronvar:
community.general.cronvar:
name: DATADOG_API_TOKEN
value: "%DATADOG_API_KEY_TEMPLATE%"
cron_file: notify_updates

- name: Cluster
cronvar:
community.general.cronvar:
name: CLUSTER
value: "%CLUSTER_TEMPLATE%"
cron_file: notify_updates

- name: Stateless instance flag
cronvar:
community.general.cronvar:
name: STATELESS_INSTANCE
value: "1"
cron_file: notify_updates
2 changes: 1 addition & 1 deletion tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
- hosts: localhost
remote_user: root
roles:
- ..
- ..
2 changes: 1 addition & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
# vars file for update-notifications
# vars file for update-notifications

0 comments on commit b022fa8

Please sign in to comment.