From 5cc66c3f583eb7e08a4c09a72ec972159915699e Mon Sep 17 00:00:00 2001 From: Sven Velt Date: Tue, 19 Nov 2024 18:29:31 +0100 Subject: [PATCH] Initial commit --- .gitignore | 164 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 32 +++++++++ defaults/main.yml | 2 + meta/main.yml | 41 ++++++++++++ tasks/main.yml | 30 +++++++++ timezone.yml | 7 ++ 6 files changed, 276 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml create mode 100644 timezone.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc4c0c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,164 @@ +# ---> Ansible +*.retry + +# ---> Python +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# ---> Vim +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ + diff --git a/README.md b/README.md new file mode 100644 index 0000000..af477cd --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# timezone + +Set timezone for different distributions + + +## Role Variables + +Defaults: +- `timezone_zone` (defaults: `Europe/Berlin`): timezone name + + +## Example Playbook + + --- + - hosts: all + + roles: + - role: timezone + vars: + timezone_zone: Europe/Berlin + + +## License + +AGPL-3.0-or-later + + +## Author Information + +Sven Velt - +https://git.velt.biz/velt.biz/ + diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..72f528f --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,2 @@ +--- +timezone_zone: Europe/Berlin diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..4f22fd9 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,41 @@ +--- +galaxy_info: + author: Sven Velt + description: Set timezone for different distributions + company: velt.biz + issue_tracker_url: https://git.velt.biz/Ansible/timezone/issues + license: AGPL-3.0-or-later + min_ansible_version: 2.1 + platforms: + - name: Alpine + - name: Debian + versions: + - stretch + - buster + - bullseye + - name: Ubuntu + versions: + - trusty + - xenial + - bionic + - focal + - groovy + - hirsute + - impish + - name: Fedora + versions: + - 38 + - 39 + - 40 + - name: EL + versions: + - 6 + - 7 + - 8 + - 9 + + galaxy_tags: + - operations + +dependencies: [] + diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..ca897ff --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,30 @@ +--- +- name: Set /etc/timezone + copy: + content: | + {{ timezone_zone }} + dest: /etc/timezone + mode: 0644 + owner: root + group: root + backup: yes + +- name: 'Look for /usr/share/zoneinfo/{{ timezone_zone }}' + stat: + path: '/usr/share/zoneinfo/{{ timezone_zone }}' + register: timezone_zoneinfo + +- name: 'Link /etc/localtime to /usr/share/zoneinfo/{{ timezone_zone }}' + file: + src: '/usr/share/zoneinfo/{{ timezone_zone }}' + dest: /etc/localtime + state: link + mode: 0644 + when: timezone_zoneinfo.stat.exists + +- name: Setup timezone for Alpine Linux + command: + cmd: '/sbin/setup-timezone {{ timezone_zone }}' + creates: '/etc/zoneinfo/{{ timezone_zone }}' + when: ansible_os_family == "Alpine" + diff --git a/timezone.yml b/timezone.yml new file mode 100644 index 0000000..869c2c2 --- /dev/null +++ b/timezone.yml @@ -0,0 +1,7 @@ +--- +- host: all + + roles: + - role: timezone +# vars: +# timezone_zone: Europe/Berlin