Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor automatic_updates #709

Merged
merged 1 commit into from
Aug 6, 2024
Merged

refactor automatic_updates #709

merged 1 commit into from
Aug 6, 2024

Conversation

konstruktoid
Copy link
Owner

No description provided.

Signed-off-by: Thomas Sjögren <[email protected]>
@konstruktoid konstruktoid merged commit 9a17dab into master Aug 6, 2024
8 checks passed
@konstruktoid konstruktoid deleted the upgrades branch August 6, 2024 23:09
@@ -77,3 +88,11 @@
group: root
mode: "0644"
create: true

- name: Configure unattended-upgrades
ansible.builtin.template:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ansible.builtin.template is destructive. Should there be a backup: yes for this?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was something with that ... iirc it was how handled the configuration if multiple files existed.
let me check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to note with this is that any file in /etc/apt/apt.conf.d will be read as config... just using backup: yes is a bad idea actually

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's the reason backup isn't used when it comes to apt configuration (and others) in the role

reboot: false
```

`automatic_updates.enabled: true` will install and configure
Copy link
Contributor

@jdaln jdaln Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One interesting thing to note (that I did not remember)

    - name: Ensure role directory for konstruktoid.hardening does not exist
      ansible.builtin.file:
        path: "{{ lookup('env', 'HOME') }}/.ansible/roles/konstruktoid.hardening"
        state: absent
      delegate_to: localhost
      run_once: true

    - name: Create the empty directory
      ansible.builtin.file:
        path: "{{ lookup('env', 'HOME') }}/.ansible/roles/konstruktoid.hardening"
        state: directory
        mode: '0755'
      delegate_to: localhost
      run_once: true

    - name: Clone hardening repository
      ansible.builtin.git:
        repo: https://github.com/konstruktoid/ansible-role-hardening.git
        dest: "{{ lookup('env', 'HOME') }}/.ansible/roles/konstruktoid.hardening"
        version: 'master'
      delegate_to: localhost
      run_once: true

    - name: Include the hardening role
      ansible.builtin.include_role:
        name: konstruktoid.hardening
      vars:
        # noqa: var-naming[no-role-prefix]
        automatic_updates.enabled: true #---> invalid variable name
        automatic_updates.reboot: true
       ....

^^^ this var notation will not work ^^^
only this will in my setup:

        automatic_updates:
          enabled: true
          reboot: true

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes. That should probably be rewritten. I meant to write the var as simple as possible, but I see now how it could be confusing.

---
- name: Various Ansible tests
  hosts: localhost
  any_errors_fatal: true
  gather_facts: false
  vars:
    automatic_updates:
      enabled: true
      reboot: true
  tasks:
    - name: Print automatic updates
      ansible.builtin.debug:
        var: automatic_updates

    - name: Get automatic updates status
      ansible.builtin.debug:
        msg: "enabled: {{ automatic_updates.enabled }}, reboot: {{ automatic_updates.reboot }}"

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants