8000 Clarification on requirements from Ansible Galaxy Collection community.general by FreddyFunk · Pull Request #140 · geerlingguy/ansible-role-ntp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Clarification on requirements from Ansible Galaxy Collection community.general #140

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .ansible-lint-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
meta/main.yml schema[meta]
15 changes: 15 additions & 0 deletions .github/workflows/ansible-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: ansible-lint
on:
pull_request:
branches: ["main", "master"]
jobs:
build:
name: Ansible Lint
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Run ansible-lint
uses: ansible/ansible-lint@main
with:
setup_python: "true"
requirements_file: "requirements.yml"
10 changes: 0 additions & 10 deletions .yamllint

This file was deleted.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ Increase the maximum root distance between the host & the ntp source.

## Dependencies

None.
Requires the Ansible Galaxy Collection `community.general` to be installed:
```bash
ansible-galaxy collection install community.general
```

## Example Playbook

Expand Down
8 changes: 4 additions & 4 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
- name: restart ntp
service:
- name: Restart ntp
ansible.builtin.service:
name: "{{ ntp_daemon }}"
state: restarted
when: ntp_enabled | bool

- name: restart cron
service:
- name: Restart cron
ansible.builtin.service:
name: "{{ ntp_cron_daemon }}"
state: restarted
when: ntp_cron_handler_enabled | bool
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ galaxy_info:
description: NTP installation and configuration for Linux.
company: "Midwestern Mac, LLC"
license: "license (BSD, MIT)"
min_ansible_version: 2.10
min_ansible_version: "2.10"
platforms:
- name: Fedora
versions:
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

pre_tasks:
- name: Update apt cache.
apt:
ansible.builtin.apt:
update_cache: true
cache_valid_time: 600
when: ansible_os_family == 'Debian'
Expand Down
5 changes: 5 additions & 0 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
collections:
- name: community.general
version: ">=10.2.0"
source: https://galaxy.ansible.com
26 changes: 13 additions & 13 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
---
- name: Include OS-specific variables.
include_vars: "{{ item }}"
ansible.builtin.include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_facts['distribution'] + '-' + ansible_facts['distribution_version'] }}.yml"
- "{{ ansible_facts['os_family'] + '-' + ansible_facts['distribution_major_version'] }}.yml"
- "{{ ansible_facts['os_family'] }}.yml"

- name: Set the ntp_driftfile variable.
set_fact:
ansible.builtin.set_fact:
ntp_driftfile: "{{ __ntp_driftfile }}"
when: ntp_driftfile is not defined

- name: Set the ntp_package variable.
set_fact:
ansible.builtin.set_fact:
ntp_package: "{{ __ntp_package }}"
when: ntp_package is not defined

- name: Set the ntp_config_file variable.
set_fact:
ansible.builtin.set_fact:
ntp_config_file: "{{ __ntp_config_file }}"
when: ntp_config_file is not defined

- name: Set the ntp_daemon variable.
set_fact:
ansible.builtin.set_fact:
ntp_daemon: "{{ __ntp_daemon }}"
when: ntp_daemon is not defined

- name: Ensure NTP package is installed.
package:
ansible.builtin.package:
name: "{{ ntp_package }}"
state: present

- name: Ensure tzdata package is installed (Linux).
package:
ansible.builtin.package:
name: "{{ ntp_tzdata_package }}"
state: present
when: ansible_system == "Linux"

- name: Set timezone.
timezone:
community.general.timezone:
name: "{{ ntp_timezone }}"
notify: restart cron

- name: Populate service facts.
service_facts:
ansible.builtin.service_facts:

- name: Disable systemd-timesyncd if it's running but ntp is enabled.
service:
ansible.builtin.service:
name: systemd-timesyncd.service
enabled: false
state: stopped
Expand All @@ -56,23 +56,23 @@
- services["systemd-timesyncd.service"]["status"] != "not-found"

- name: Ensure NTP is running and enabled as configured.
service:
ansible.builtin.service:
name: "{{ ntp_daemon }}"
state: started
enabled: true
when: ntp_enabled | bool
ignore_errors: "{{ ansible_check_mode }}"

- name: Ensure NTP is stopped and disabled as configured.
service:
ansible.builtin.service:
name: "{{ ntp_daemon }}"
state: stopped
enabled: false
when: not (ntp_enabled | bool)
ignore_errors: "{{ ansible_check_mode }}"

- name: Generate ntp configuration file.
template:
ansible.builtin.template:
src: "{{ ntp_config_file | basename }}.j2"
dest: "{{ ntp_config_file }}"
mode: 0644
Expand Down
0