diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..4ba765e --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +*.yml linguist-detectable=true +*.yaml linguist-detectable=true +*.html linguist-detectable=false \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 7b75bfc..c441860 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,9 @@ python: "3.9" os: linux services: - docker +before_install: + - echo '{"default-cgroupns-mode":"host"}' | sudo tee /etc/docker/daemon.json + - sudo systemctl restart docker install: - pip install pipenv - pipenv sync @@ -20,6 +23,9 @@ env: - MOLECULE_DISTRO=debian:bullseye-slim SCENARIO=default - MOLECULE_DISTRO=debian:bullseye-slim SCENARIO=timer-create-config - MOLECULE_DISTRO=debian:bullseye-slim SCENARIO=timer-to-hourly + - MOLECULE_DISTRO=debian:bookworm-slim SCENARIO=default + - MOLECULE_DISTRO=debian:bookworm-slim SCENARIO=timer-create-config + - MOLECULE_DISTRO=debian:bookworm-slim SCENARIO=timer-to-hourly script: - pipenv run molecule test --scenario-name=${SCENARIO} diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a8ed3c..e1f9d99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a changelog](https://github.com/olivierlacan/keep-a-changelog). +## Added +- *[#12](https://github.com/idealista/logrotate_role/pull/12) (2024-01-17)- Add ".gitattributes" file for linguist detection.* @ygomezsaiz + ## [Unreleased](https://github.com/idealista/logrotate_role/tree/develop) +## [3.0.3](https://github.com/idealista/logrotate_role/tree/3.0.3) + +### Fixed + +### Added + +- Add Debian 12 support + +### Changed + +### Removed + ## [3.0.2](https://github.com/idealista/logrotate_role/tree/3.0.2) ### Fixed diff --git a/molecule/cron-create-config/Dockerfile.j2 b/molecule/cron-create-config/Dockerfile.j2 index c275c2a..4ca6b01 100644 --- a/molecule/cron-create-config/Dockerfile.j2 +++ b/molecule/cron-create-config/Dockerfile.j2 @@ -6,6 +6,19 @@ FROM {{ item.registry.url }}/{{ item.image }} FROM {{ item.image }} {% endif %} +{% if item.image == 'debian:stretch-slim' %} +RUN rm /etc/apt/sources.list.d/* || true +RUN echo "deb http://archive.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list && \ + echo "deb-src http://archive.debian.org/debian/ stretch main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb http://archive.debian.org/debian-security stretch/updates main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb-src http://archive.debian.org/debian-security stretch/updates main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb http://archive.debian.org/debian/ stretch-backports main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb-src http://archive.debian.org/debian/ stretch-backports main contrib non-free" >> /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y --force-yes python3 sudo bash ca-certificates iproute2 systemd systemd-sysv && \ + apt-get clean +{% endif %} + # install minimal packages for debian slim images RUN apt-get update && \ apt-get install -y python sudo bash ca-certificates iproute2 systemd systemd-sysv python-pip && \ diff --git a/molecule/cron-create-config/molecule.yml b/molecule/cron-create-config/molecule.yml index b11622a..9322199 100644 --- a/molecule/cron-create-config/molecule.yml +++ b/molecule/cron-create-config/molecule.yml @@ -23,7 +23,7 @@ platforms: - /run - /run/lock volumes: - - '/sys/fs/cgroup:/sys/fs/cgroup:ro' + - '/sys/fs/cgroup:/sys/fs/cgroup' command: '/lib/systemd/systemd' stop_signal: 'RTMIN+3' diff --git a/molecule/cron-default/Dockerfile.j2 b/molecule/cron-default/Dockerfile.j2 index c275c2a..4ca6b01 100644 --- a/molecule/cron-default/Dockerfile.j2 +++ b/molecule/cron-default/Dockerfile.j2 @@ -6,6 +6,19 @@ FROM {{ item.registry.url }}/{{ item.image }} FROM {{ item.image }} {% endif %} +{% if item.image == 'debian:stretch-slim' %} +RUN rm /etc/apt/sources.list.d/* || true +RUN echo "deb http://archive.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list && \ + echo "deb-src http://archive.debian.org/debian/ stretch main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb http://archive.debian.org/debian-security stretch/updates main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb-src http://archive.debian.org/debian-security stretch/updates main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb http://archive.debian.org/debian/ stretch-backports main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb-src http://archive.debian.org/debian/ stretch-backports main contrib non-free" >> /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y --force-yes python3 sudo bash ca-certificates iproute2 systemd systemd-sysv && \ + apt-get clean +{% endif %} + # install minimal packages for debian slim images RUN apt-get update && \ apt-get install -y python sudo bash ca-certificates iproute2 systemd systemd-sysv python-pip && \ diff --git a/molecule/cron-default/molecule.yml b/molecule/cron-default/molecule.yml index 8b2f25d..dbd4aff 100644 --- a/molecule/cron-default/molecule.yml +++ b/molecule/cron-default/molecule.yml @@ -23,7 +23,7 @@ platforms: - /run - /run/lock volumes: - - '/sys/fs/cgroup:/sys/fs/cgroup:ro' + - '/sys/fs/cgroup:/sys/fs/cgroup' command: '/lib/systemd/systemd' stop_signal: 'RTMIN+3' diff --git a/molecule/cron-to-hourly/Dockerfile.j2 b/molecule/cron-to-hourly/Dockerfile.j2 index c275c2a..4ca6b01 100644 --- a/molecule/cron-to-hourly/Dockerfile.j2 +++ b/molecule/cron-to-hourly/Dockerfile.j2 @@ -6,6 +6,19 @@ FROM {{ item.registry.url }}/{{ item.image }} FROM {{ item.image }} {% endif %} +{% if item.image == 'debian:stretch-slim' %} +RUN rm /etc/apt/sources.list.d/* || true +RUN echo "deb http://archive.debian.org/debian/ stretch main contrib non-free" > /etc/apt/sources.list && \ + echo "deb-src http://archive.debian.org/debian/ stretch main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb http://archive.debian.org/debian-security stretch/updates main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb-src http://archive.debian.org/debian-security stretch/updates main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb http://archive.debian.org/debian/ stretch-backports main contrib non-free" >> /etc/apt/sources.list && \ + echo "deb-src http://archive.debian.org/debian/ stretch-backports main contrib non-free" >> /etc/apt/sources.list && \ + apt-get update && \ + apt-get install -y --force-yes python3 sudo bash ca-certificates iproute2 systemd systemd-sysv && \ + apt-get clean +{% endif %} + # install minimal packages for debian slim images RUN apt-get update && \ apt-get install -y python sudo bash ca-certificates iproute2 systemd systemd-sysv python-pip && \ diff --git a/molecule/cron-to-hourly/molecule.yml b/molecule/cron-to-hourly/molecule.yml index a50bf1a..c640723 100644 --- a/molecule/cron-to-hourly/molecule.yml +++ b/molecule/cron-to-hourly/molecule.yml @@ -23,7 +23,7 @@ platforms: - /run - /run/lock volumes: - - '/sys/fs/cgroup:/sys/fs/cgroup:ro' + - '/sys/fs/cgroup:/sys/fs/cgroup' command: '/lib/systemd/systemd' stop_signal: 'RTMIN+3' diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2 index 1b21ff9..b66cbd9 100644 --- a/molecule/default/Dockerfile.j2 +++ b/molecule/default/Dockerfile.j2 @@ -7,7 +7,7 @@ FROM {{ item.image }} {% endif %} # install minimal packages for debian slim images -{% if item.image == 'debian:bullseye-slim' %} +{% if item.image == 'debian:bullseye-slim' or item.image == 'debian:bookworm-slim' %} RUN apt-get update && \ apt-get install -y python3 sudo bash ca-certificates iproute2 systemd systemd-sysv python3-pip && \ apt-get clean diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index bc10979..7b0dbaf 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -23,7 +23,7 @@ platforms: - /run - /run/lock volumes: - - '/sys/fs/cgroup:/sys/fs/cgroup:ro' + - '/sys/fs/cgroup:/sys/fs/cgroup' command: '/lib/systemd/systemd' stop_signal: 'RTMIN+3' diff --git a/molecule/timer-create-config/Dockerfile.j2 b/molecule/timer-create-config/Dockerfile.j2 index 1b21ff9..b66cbd9 100644 --- a/molecule/timer-create-config/Dockerfile.j2 +++ b/molecule/timer-create-config/Dockerfile.j2 @@ -7,7 +7,7 @@ FROM {{ item.image }} {% endif %} # install minimal packages for debian slim images -{% if item.image == 'debian:bullseye-slim' %} +{% if item.image == 'debian:bullseye-slim' or item.image == 'debian:bookworm-slim' %} RUN apt-get update && \ apt-get install -y python3 sudo bash ca-certificates iproute2 systemd systemd-sysv python3-pip && \ apt-get clean diff --git a/molecule/timer-create-config/molecule.yml b/molecule/timer-create-config/molecule.yml index ad7a9db..0a998e4 100644 --- a/molecule/timer-create-config/molecule.yml +++ b/molecule/timer-create-config/molecule.yml @@ -23,7 +23,7 @@ platforms: - /run - /run/lock volumes: - - '/sys/fs/cgroup:/sys/fs/cgroup:ro' + - '/sys/fs/cgroup:/sys/fs/cgroup' command: '/lib/systemd/systemd' stop_signal: 'RTMIN+3' diff --git a/molecule/timer-to-hourly/Dockerfile.j2 b/molecule/timer-to-hourly/Dockerfile.j2 index 1b21ff9..b66cbd9 100644 --- a/molecule/timer-to-hourly/Dockerfile.j2 +++ b/molecule/timer-to-hourly/Dockerfile.j2 @@ -7,7 +7,7 @@ FROM {{ item.image }} {% endif %} # install minimal packages for debian slim images -{% if item.image == 'debian:bullseye-slim' %} +{% if item.image == 'debian:bullseye-slim' or item.image == 'debian:bookworm-slim' %} RUN apt-get update && \ apt-get install -y python3 sudo bash ca-certificates iproute2 systemd systemd-sysv python3-pip && \ apt-get clean diff --git a/molecule/timer-to-hourly/molecule.yml b/molecule/timer-to-hourly/molecule.yml index 8ce02ad..16611f3 100644 --- a/molecule/timer-to-hourly/molecule.yml +++ b/molecule/timer-to-hourly/molecule.yml @@ -23,7 +23,7 @@ platforms: - /run - /run/lock volumes: - - '/sys/fs/cgroup:/sys/fs/cgroup:ro' + - '/sys/fs/cgroup:/sys/fs/cgroup' command: '/lib/systemd/systemd' stop_signal: 'RTMIN+3' diff --git a/tasks/config-Debian-12.yml b/tasks/config-Debian-12.yml new file mode 100644 index 0000000..674a4d4 --- /dev/null +++ b/tasks/config-Debian-12.yml @@ -0,0 +1,30 @@ +--- + +- name: LOGROTATE | Set facts + set_fact: + options: "{{ options|default([]) + item }}" + with_items: + - "{{ logrotate_config_file | json_query( '[*].options' ) }}" + tags: + - config + - config-frequency + +- name: LOGROTATE | Changing timer to hourly + set_fact: + logrotate_timer_oncalendar: "{{ logrotate_timer_oncalendar_hourly }}" + logrotate_timer_accuracysec: "{{ logrotate_timer_accuracysec_hourly }}" + when: "'hourly' in options" + tags: + - config + - config-frequency + +- name: LOGROTATE | Add timer + template: + src: "{{ logrotate_j2_timer }}" + dest: "{{ logrotate_systemd_path }}/{{ logrotate_timer }}" + mode: 0644 + become: true + notify: start timer + tags: + - config + - config-frequency