1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_ntp.git synced 2024-08-16 12:59:49 +02:00

add ntp package install

This commit is contained in:
diodonfrost 2018-12-28 11:54:06 +01:00
parent b6a70affa7
commit 712e708bea
11 changed files with 276 additions and 82 deletions

View file

@ -145,9 +145,9 @@ platforms:
# Archlinux
- name: archlinux-rolling
driver:
image: diodonfrost/opensuse-13.2-ansible
image: diodonfrost/archlinux-rolling-ansible
run_command: /usr/lib/systemd/systemd
platform: opensuse
platform: arch
provision_command:
- sed -i 's/UsePAM yes/UsePAM no/g' /etc/ssh/sshd_config
- systemctl enable sshd

205
README.md
View file

@ -1,38 +1,195 @@
Role Name
=========
# ansible-role-ntp
A brief description of the role goes here.
[![Build Status](https://travis-ci.org/diodonfrost/ansible-role-ntp.svg?branch=master)](https://travis-ci.org/diodonfrost/ansible-role-ntp)
[![Ansible Galaxy](https://img.shields.io/badge/galaxy-diodonfrost.ntp-660198.svg)](https://galaxy.ansible.com/diodonfrost/ntp)
Requirements
------------
his role provide a compliance for install ntp on your target host.
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.
## Requirements
Role Variables
--------------
This role was developed using Ansible 2.4 Backwards compatibility is not guaranteed.
Use `ansible-galaxy install diodonfrost.ntp` to install the role on your system.
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.
Supported platforms:
Dependencies
------------
```yaml
- name: EL
versions:
- 7
- 6
- 5
- name: Fedora
versions:
- 29
- 28
- 27
- 26
- name: Debian
versions:
- stretch
- jessie
- wheezy
- squeeze
- name: Ubuntu
versions:
- bionic
- xenial
- trusty
- precise
- trusty
- name: OracleLinux
versions:
- 7
- 6
- name: Amazon
versions:
- 2017.12
- 2016.03
- 2013.09
- name: opensuse
versions:
- 13.2
- 42.1
- 42.2
- 42.3
- name: SLES
versions:
- 11
- 12
- 15
- name: ArchLinux
versions:
- any
- name: Gentoo
versions:
- stage3
```
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.
## Role Variables
Example Playbook
----------------
This role has multiple variables. The defaults for all these variables are the following:
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
```yaml
---
# defaults file for ansible-role-ntp
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
# Specify ntp version to install
# Depends on the operating system
# Accepted value: 6,7,8,9,11,latest
# latest take latest version of ntp supported by operating system
# Default latest
ntp_version: latest
License
-------
# Install ntp virtual machine
# Default is true
openjre_install: true
BSD
# Install ntp virtual machine and development kit for ntp
# Default is false
openjdk_install: false
```
Author Information
------------------
## Dependencies
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
None
## Example Playbook
This is a sample playbook file for deploying the Ansible Galaxy ntp role in a localhost and installing openjdk-jre.
```yaml
---
- hosts: localhost
become: true
roles:
- role: diodonfrost.ntp
```
## Local Testing
The preferred way of locally testing the role is to use Docker. You will have to install Docker on your system.
You can also use vagrant and Virtualbox with vagrant to run tests locally. You will have to install Virtualbox and Vagrant on your system. For all our tests we use test-kitchen.
Next install test-kitchen:
```shell
# Install dependencies
gem install bundler
bundle install
```
### Testing with Docker
```shell
# List all tests with kitchen
kitchen list
# fast test on one machine
kitchen test default-centos-7
# test on all machines
kitchen test
# for development, create environment
kitchen create default-centos-7
# Apply ansible playbook
kitchen converge default-centos-7
# Apply inspec tests
kitchen verify default-centos-7
```
### Testing with Virtualbox
```shell
# Specify kitchen file on Linux
export KITCHEN_YAML=.kitchen-vagrant.yml
# fast test on one machine
kitchen test os-packaging-freebsd-112
```
### Testing Windows and Solaris with Virtualbox
Windows and Solaris can only be test with Virtualbox provider,do not use 'kitchen test' command for testing Windows and Solaris environment. There 4 steps you will be using with test-kitchen as part of your workflow.
First of all we must set the kitchen file:
```shell
# For testing Windows
export KITCHEN_YAML=.kitchen-windows.yml
# For testing Solaris
export KITCHEN_YAML=.kitchen-solaris.yml
```
Provision the virtual machines, a Linux machine to run Ansible and Windows/Solaris machines to apply playbook again:
```shell
# deploy machines
kitchen create
# Launch playbook
kitchen converge
```
Finaly launch inspec tests:
```shell
kitchen verify
```
For cleaning environment use:
```shell
kitchen destroy
```
## License
Apache 2
## Resources
[ntp on ubuntu](https://doc.ubuntu-fr.org/ntp)
## Author Information
This role was created in 2018 by diodonfrost.

View file

@ -1,60 +1,67 @@
galaxy_info:
author: your name
description: your description
company: your company (optional)
role_name: ntp
author: diodonfrost
company: diodonfrost
description: Ansible role for manage ntp daemon on a large number of os
license: license Apache
# 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
min_ansible_version: 2.7
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
platforms:
- name: EL
versions:
- 7
- 6
- 5
- name: Fedora
versions:
- 29
- 28
- 27
- 26
- name: Debian
versions:
- stretch
- jessie
- wheezy
- squeeze
- name: Ubuntu
versions:
- bionic
- xenial
- trusty
- precise
- trusty
- name: OracleLinux
versions:
- 7
- 6
- name: Amazon
versions:
- 2017.12
- 2016.03
- 2013.09
- name: opensuse
versions:
- 13.2
- 42.1
- 42.2
- 42.3
- name: SLES
versions:
- 11
- 12
- 15
- name: ArchLinux
versions:
- any
- name: Gentoo
versions:
- stage3
min_ansible_version: 2.4
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
# Optionally specify the branch Galaxy will use when accessing the GitHub
# repo for this role. During role install, if no tags are available,
# Galaxy will use this branch. During import Galaxy will access files on
# this branch. If Travis integration is configured, only notifications for this
# branch will be accepted. Otherwise, in all cases, the repo's default branch
# (usually master) will be used.
#github_branch:
#
# 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.
galaxy_tags:
- system
- packaging
- ntp
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

View file

@ -1,2 +1,8 @@
---
# tasks file for ansible-role-ntp
# Main tasks file for ansible-role-ntp
- name: Include OS specific variables.
include_vars: "{{ ansible_os_family }}.yml"
- name: Install ntp agent
include_tasks: "packages/setup-{{ ansible_system }}.yml"

View file

@ -0,0 +1,13 @@
---
# Tasks file for install ntp daemon on Linux system
- name: Install ntp daemon on Linux
package:
name: "{{ ntp_package }}"
state: present
- name: Service ntp on Linux
service:
name: "{{ ntp_service }}"
enabled: yes
state: started

View file

@ -1,7 +1,8 @@
# Test ntp daemon install
ntp_package = "ntp"
ntp_service = "ntp"
ntp_service = "ntpd"
ntp_service = "ntp" if os.family == "debian"
control 'install-01' do
impact 1.0

2
vars/Archlinux.yml Normal file
View file

@ -0,0 +1,2 @@
ntp_package: ntp
ntp_service: ntpd

2
vars/Debian.yml Normal file
View file

@ -0,0 +1,2 @@
ntp_package: ntp
ntp_service: ntp

2
vars/Gentoo.yml Normal file
View file

@ -0,0 +1,2 @@
ntp_package: net-misc/ntp
ntp_service: ntp-client

2
vars/RedHat.yml Normal file
View file

@ -0,0 +1,2 @@
ntp_package: ntp
ntp_service: ntpd

2
vars/Suse.yml Normal file
View file

@ -0,0 +1,2 @@
ntp_package: ntp
ntp_service: ntp