0.1.0-DEV-20200429-233815

-------------------------
    * INITIAL:
      - initial commit for zen_ntp ansible role
This commit is contained in:
Chris Hammer 2020-04-29 23:40:42 -04:00
commit ea2a253234
11 changed files with 275 additions and 0 deletions

9
.ansible-lint Normal file
View File

@ -0,0 +1,9 @@
parseable: true
quiet: false
skip_list:
- '010'
- '201'
- '305'
- '403'
use_default_rules: true
verbosity: 1

84
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,84 @@
# CI Mark that build is executed in CI environment
# GITLAB_CI Mark that build is executed in GitLab CI environment
# CI_SERVER Mark that build is executed in CI environment
# CI_SERVER_NAME CI server that is used to coordinate builds
# CI_SERVER_VERSION Not yet defined
# CI_SERVER_REVISION Not yet defined
# CI_BUILD_REF The commit revision for which project is built
# CI_BUILD_BEFORE_SHA The first commit that were included in push request
# CI_BUILD_REF_NAME The branch or tag name for which project is built
# CI_BUILD_ID The unique id of the current build that GitLab CI uses internally
# CI_BUILD_REPO The URL to clone the Git repository
# CI_PROJECT_ID The unique id of the current project that GitLab CI uses internally
# CI_PROJECT_DIR The full path where the repository is cloned and where the build is ran
variables:
ANSIBLE_ROLE: "zen_ntp"
ANSIBLE_ROLE_PATH: "${CI_PROJECT_DIR}"
ANSIBLE_EXTRA_VARS: ""
stages:
- check_and_lint
- test_deploy
### BEGIN TEMPLATES ###
.tags_template: &tags_template
tags:
- zen-ci
.header_template: &header
variables:
DOCKER_IMG_TAG: "7.7.1908"
.check_versions_template: &check_vers
<<: *tags_template
stage: check_and_lint
only:
- development
script:
- /usr/bin/hostname
- "cd ${CI_PROJECT_DIR} && git log -1"
- "ansible --version"
- "ansible-lint --version"
.lint_play_template: &lint_play
<<: *tags_template
stage: check_and_lint
only:
- development
script:
- "ansible-lint -v ${ANSIBLE_ROLE_PATH}"
.test_deploy_template: &test_deploy
<<: *tags_template
stage: test_deploy
only:
- development
script:
- cp -av ${ANSIBLE_ROLE_PATH} /etc/ansible/roles/${ANSIBLE_ROLE}
- ansible-playbook -v --connection=local ${ANSIBLE_EXTRA_VARS} tests/test.yml
### END TEMPLATES ###
### BEGIN JOBS ###
Version Checks:
<<: *header
<<: *check_vers
Lint Play:
<<: *header
<<: *lint_play
Test Deploy:
<<: *header
<<: *test_deploy
### END JOBS ###

38
README.md Normal file
View File

@ -0,0 +1,38 @@
Role Name
=========
A brief description of the role goes here.
Requirements
------------
Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including any variables that are in defaults/main.yml, vars/main.yml, and any variables that can/should be set via parameters to the role. Any variables that are read from other roles and/or the global scope (ie. hostvars, group vars, etc.) should be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).

22
defaults/main.yml Normal file
View File

@ -0,0 +1,22 @@
---
# defaults file for zen_ntp
ntp_conf_file : "/etc/ntp.conf"
ntp_conf_version : "1.0"
ntp_conf_revision : "20200429-232122"
ntp_node_type : server
ntp_network : 10.0.0.0
ntp_netmask : 255.0.0.0
ntp_lan_server : 10.10.10.55
ntp_servers :
- 0.centos.pool.ntp.org
- 1.centos.pool.ntp.org
- 2.centos.pool.ntp.org

7
handlers/main.yml Normal file
View File

@ -0,0 +1,7 @@
---
# handlers file for zen_ntp
- name: restart ntpd
service:
name : ntpd
state: restarted
when: ansible_virtualization_type != "docker"

53
meta/main.yml Normal file
View File

@ -0,0 +1,53 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
min_ansible_version: 2.9
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99
galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

25
tasks/main.yml Normal file
View File

@ -0,0 +1,25 @@
---
# tasks file for zen_ntp
- name: install ntp if not present
package:
name : ntp
state : present
- name: deploy {{ ntp_conf_file }}
template:
src: templates/ntp_conf.j2
dest: "{{ ntp_conf_file }}"
mode: 0644
owner: root
group: root
notify: restart ntpd
- name: enable/start ntpd
service:
name: ntpd
enabled: yes
state: started
when: ansible_distribution_major_version == "7" and ansible_virtualization_type != "docker"

28
templates/ntp_conf.j2 Normal file
View File

@ -0,0 +1,28 @@
#####################################################
# The Zen Garden Network #
# #
# Configuration : {{ ntp_conf_file }} #
# Version : {{ ntp_conf_version }}-{{ ntp_conf_revision }} #
# #
# Chris H. <chris@thezengarden.net> #
#####################################################
driftfile /var/lib/ntp/drift
restrict 127.0.0.1
restrict ::1
restrict {{ ntp_network }} mask {{ ntp_netmask }} nomodify notrap
{% if ntp_node_type == "server" %}
{% for server in ntp_servers %}
server {{ server }}
{% endfor %}
{% else %}
server {{ ntp_lan_server }}
{% endif %}
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor

2
tests/inventory Normal file
View File

@ -0,0 +1,2 @@
localhost

5
tests/test.yml Normal file
View File

@ -0,0 +1,5 @@
---
- hosts: localhost
remote_user: root
roles:
- zen_ntp

2
vars/main.yml Normal file
View File

@ -0,0 +1,2 @@
---
# vars file for zen_ntp