Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/os_builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ jobs:
cd os_builders &&
packer init . &&
packer validate -syntax-only .
env:
PACKER_GITHUB_API_TOKEN: ${{ secrets.PACKER_GITHUB_API_TOKEN }}

test_image_build_ubuntu:
strategy:
Expand All @@ -48,7 +50,7 @@ jobs:
run: |
. venv/bin/activate
cd os_builders
ansible-playbook configure_os_images.yml -i ../.github/localhost.yml --extra-vars tidy_image=false
ansible-playbook configure_os_images.yml -i ../.github/localhost.yml

test_image_build_rocky:
strategy:
Expand All @@ -66,4 +68,4 @@ jobs:
- name: Run configure_os_images playbook
run: |
cd os_builders
ansible-playbook configure_os_images.yml -i ../.github/localhost.yml --extra-vars tidy_image=false
ansible-playbook configure_os_images.yml -i ../.github/localhost.yml
2 changes: 1 addition & 1 deletion os_builders/configure_os_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
- role: container_registry
- role: nubes_bootcontext
- role: tidy_image
when: "{{ tidy_image | default(true) | bool == true }}"

1 change: 1 addition & 0 deletions os_builders/roles/tidy_image/tasks/clear_audit_log.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
block:
- name: Clear Audit log
shell: "/bin/cat /dev/null > /var/log/audit/audit.log"
ignore_errors: true
when: ansible_distribution == "Rocky"
become: true

Expand Down
2 changes: 1 addition & 1 deletion os_builders/roles/tidy_image/tasks/logrotate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


- name: Clear Audit log
shell: "sudo logrotate -f /etc/logrotate.conf"
shell: "logrotate -f /etc/logrotate.conf"
become: true

- name: Cleanout /var/log/*.gz
Expand Down
12 changes: 11 additions & 1 deletion os_builders/roles/tidy_image/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
# Cleanup machine

- name: Check if we are in a container from the GitHub workflows
become: true
ansible.builtin.command: "cat /proc/self/cgroup"
register: in_container_check

- name: set_fact for checking container
ansible.builtin.set_fact:
in_container: "{{ in_container_check.stdout != '0::/' }}"

- include_tasks: reboot.yml
when: in_container

- include_tasks: get_package_facts.yml
- include_tasks: run_quattor.yml
when: ansible_distribution == "Rocky"
- include_tasks: get_package_facts.yml
- include_tasks: cleanout_tmp.yml
- include_tasks: cleanout_rc_directories.yml
- include_tasks: cleanup_network_conf.yml
- include_tasks: run_update_keys.yml
- include_tasks: set_locale.yml
- include_tasks: wazuh.yml
- include_tasks: cleanup_quattor.yml
Expand Down
1 change: 1 addition & 0 deletions os_builders/roles/tidy_image/tasks/run_pakiti.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
command:
cmd: "pakiti2-client"
become: true
when: in_container
2 changes: 1 addition & 1 deletion os_builders/roles/tidy_image/tasks/run_quattor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: run quattor
shell: "sudo quattor-fetch && sudo quattor-configure --all --verbose"
shell: "quattor-fetch && quattor-configure --all --verbose"
ignore_errors: true
when: ansible_distribution == "Rocky"
become: true
4 changes: 0 additions & 4 deletions os_builders/roles/tidy_image/tasks/run_update_keys.yml

This file was deleted.

39 changes: 21 additions & 18 deletions os_builders/roles/tidy_image/tasks/set_locale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,31 @@
when: not ansible_check_mode and found_language.rc != 0
become: true

- name: Get current locale and language configuration
command: localectl status
register: locale_status
changed_when: false
become: true
- name: configure locale
block:
- name: Get current locale and language configuration
command: localectl status
register: locale_status
changed_when: false
become: true

- name: Parse 'LANG' from current locale and language configuration
set_fact:
locale_lang: "{{ locale_status.stdout | regex_search('LANG=([^\n]+)', '\\1') | first }}"
- name: Parse 'LANG' from current locale and language configuration
set_fact:
locale_lang: "{{ locale_status.stdout | regex_search('LANG=([^\n]+)', '\\1') | first }}"

- name: Parse 'LANGUAGE' from current locale and language configuration
set_fact:
locale_language: "{{ locale_status.stdout | regex_search('LANGUAGE=([^\n]+)', '\\1') | default([locale_lang], true) | first }}"
- name: Parse 'LANGUAGE' from current locale and language configuration
set_fact:
locale_language: "{{ locale_status.stdout | regex_search('LANGUAGE=([^\n]+)', '\\1') | default([locale_lang], true) | first }}"

- name: Configure locale to '{{ config_system_locale }}' and language to '{{ config_system_language }}'
command: localectl set-locale LANG={{ config_system_locale }} LANGUAGE={{ config_system_language }}
become: true
- name: Configure locale to '{{ config_system_locale }}' and language to '{{ config_system_language }}'
command: localectl set-locale LANG={{ config_system_locale }} LANGUAGE={{ config_system_language }}
become: true

- name: Set locale keymap
command: localectl set-keymap gb
when: ansible_distribution == "Rocky"
become: true
- name: Set locale keymap
command: localectl set-keymap gb
when: ansible_distribution == "Rocky"
become: true
when: in_container

# - name: Set locale keymap
# command: loadkeys uk
Expand Down
1 change: 1 addition & 0 deletions os_builders/roles/tidy_image/tasks/wazuh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
when: wazuh_package_name in ansible_facts.packages
ignore_errors: True
become: true
when: in_container

- name: Clean Wazuh agent history
file:
Expand Down
2 changes: 2 additions & 0 deletions os_builders/roles/vm_baseline/files/update_keys.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -x

if ls /home/cloud
then
KEYSPATH=/home/cloud
Expand Down
18 changes: 18 additions & 0 deletions os_builders/roles/vm_baseline/tasks/locale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
- name: Install locales on Debian
ansible.builtin.apt:
name: locales
state: present
update_cache: true
become: true
when: ansible_os_family == "Debian"

- name: Install locales on RedHat
ansible.builtin.dnf:
name:
- glibc-locale-source
- glibc-langpack-en
state: present
become: true
when: ansible_os_family == "RedHat"

1 change: 1 addition & 0 deletions os_builders/roles/vm_baseline/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

- include_tasks: cron.yml
- include_tasks: grub-cmdline.yml
- include_tasks: locale.yml

- include_tasks: ssh.yml
- include_tasks: rsyslog.yml
Expand Down