diff --git a/.github/workflows/deploy.yml b/.github/workflows/publish.yml similarity index 100% rename from .github/workflows/deploy.yml rename to .github/workflows/publish.yml diff --git a/defaults/main.yml b/defaults/main.yml index c412feb..3b100a2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,2 @@ --- -# defaults file for update-notifications \ No newline at end of file +# defaults file for update-notifications diff --git a/files/yum-cron-notify.conf b/files/dnf-automatic.conf similarity index 57% rename from files/yum-cron-notify.conf rename to files/dnf-automatic.conf index 6b67d9f..6d7548e 100644 --- a/files/yum-cron-notify.conf +++ b/files/dnf-automatic.conf @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/files/notify_updates b/files/notify_updates index fb12de6..ca35760 100755 --- a/files/notify_updates +++ b/files/notify_updates @@ -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 diff --git a/handlers/main.yml b/handlers/main.yml index 6837c4a..db5a81d 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,2 +1,2 @@ --- -# handlers file for update-notifications \ No newline at end of file +# handlers file for update-notifications diff --git a/meta/main.yml b/meta/main.yml index eb24b21..7f64de6 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -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 @@ -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: @@ -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 @@ -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. diff --git a/tasks/main.yml b/tasks/main.yml index f7338da..d20bcda 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 diff --git a/tests/test.yml b/tests/test.yml index 704348c..ed3f37b 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -2,4 +2,4 @@ - hosts: localhost remote_user: root roles: - - .. \ No newline at end of file + - .. diff --git a/vars/main.yml b/vars/main.yml index bd64053..c2ea368 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,2 +1,2 @@ --- -# vars file for update-notifications \ No newline at end of file +# vars file for update-notifications