initial commit
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..75a0526 --- /dev/null +++ b/.gitignore
@@ -0,0 +1,112 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# 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/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*,cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# IPython Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# dotenv +.env + +# virtualenv +venv/ +ENV/ + +# Spyder project settings +.spyderproject + +# Rope project settings +.ropeproject + +.vagrant +*.iml +archives +.DS_Store +ssh_keys +ansible.log +*.zip +license.txt +*.log +*.tar.gz +*.rpm +*.tar +ansible_fact_cache_dir +*jar +.ansible_cache* +configs_and_logs +redhat-rhui.repo +rhui-load-balancers.conf +out +.idea +*iml +*retry
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..36bbf62 --- /dev/null +++ b/.travis.yml
@@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file
diff --git a/README.md b/README.md new file mode 100644 index 0000000..4297ef5 --- /dev/null +++ b/README.md
@@ -0,0 +1,54 @@ +Apigee Time Sync +================ + +This roles installs and minimally configures ntpd and sets the locale for an Apigee OPDK installation. + +Requirements +------------ + +A local ntp server can be specified by uncommenting and setting the preferred_server_ip variable. The installation of +Apigee OPDK requires root access. Credentials must also be supplied to override the empty placeholders +provided here. It is recommended that credentials be consolidated into a single credentials.yml file that can be stored +separately. It is assumed that files containing credentials are stored in the ~/.apigee folder. + +Role Variables +-------------- + +Set this to the desired timezone file + + timezone: /usr/share/zoneinfo/America/New_York + +This is set as the preferred ntp server, feel free to set your own. + + preferred_server_ip: 128.138.141.172 + +Location of the drift file + + drift_filename: /var/lib/ntp/drift + + +Location of the ntp stats dir + + stats_dir: /var/log/ntpstats + +Location of the ntp configuration file + + ntp_conf: /etc/ntp.conf + + +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: '{{ hosts }}' + become: true + + roles: + - opdk-time-sync + +Author Information +------------------ + +Carlos Frias
diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..9aaa29e --- /dev/null +++ b/defaults/main.yml
@@ -0,0 +1,15 @@ +--- +# Defaults file for apigee-time-sync +timezone: /usr/share/zoneinfo/America/New_York + +# Preferred_server_ip to set a local ntp server +preferred_server_ip: 128.138.141.172 + +# Location of the drift file +drift_filename: /var/lib/ntp/drift + +# Location of the ntp stats directory +stats_dir: /var/log/ntpstats + +# Location of the ntp configuration file +ntp_conf: /etc/ntp.conf
diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..ce20350 --- /dev/null +++ b/handlers/main.yml
@@ -0,0 +1,2 @@ +--- +# handlers file for apigee-time-sync
diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..4931fa8 --- /dev/null +++ b/meta/main.yml
@@ -0,0 +1,46 @@ +galaxy_info: + author: Carlos Frias + description: Minimumally configure NTP server to enable Apigee Edge to function correctly. + company: Apigee + + # 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 + + # Some suggested licenses: + # - BSD (default) + # - MIT + # - GPLv2 + # - GPLv3 + # - Apache + # - CC-BY + license: Apache License Version 2.0, January 2004 + + min_ansible_version: 2.1 + + # 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 cofigured, only notification for this + # branch will be accepted. Otherwise, in all cases, the repo's default branch + # (usually master) will be used. + #github_branch: + + # + # Below are all platforms currently available. Just uncomment + # the ones that apply to your role. If you don't see your + # platform on this list, let us know and we'll get it added! + # + platforms: + - name: EL + versions: + - 6 + - 7 + + galaxy_tags: + - apigee + - opdk + - api + - system + +dependencies: []
diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..6b8389c --- /dev/null +++ b/tasks/main.yml
@@ -0,0 +1,48 @@ +--- +# tasks file for apigee-time-sync +- name: Update yum os packages + yum: + name: "{{ item }}" + state: present + with_items: + - ntp + - ntpdate + +- name: Update statsdir + lineinfile: + dest: '{{ ntp_conf }}' + line: 'statsdir {{ stats_dir }}' + insertafter: '^driftfile {{ drift_filename }}' + backup: yes + +- name: Create dirs + file: + path: '{{ item }}' + state: directory + with_items: + - '{{ stats_dir }}' + +- name: Update with preferred iburst if provided + lineinfile: + dest: '{{ ntp_conf }}' + line: 'server {{ preferred_server_ip }} iburst prefer' + insertbefore: '^server 0.*$' + state: present + backup: yes + when: preferred_server_ip is defined + +- name: Prepare to update locale + file: + path: /etc/localtime + state: absent + +- name: Update locale + file: + dest: /etc/localtime + src: '{{ timezone }}' + state: link + +- name: Start ntp server + service: + name: ntpd + state: restarted
diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..d18580b --- /dev/null +++ b/tests/inventory
@@ -0,0 +1 @@ +localhost \ No newline at end of file
diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..ef7de7a --- /dev/null +++ b/tests/test.yml
@@ -0,0 +1,6 @@ +--- +- hosts: localhost + become: yes + + roles: + - apigee-time-sync \ No newline at end of file
diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..8ae9105 --- /dev/null +++ b/vars/main.yml
@@ -0,0 +1,2 @@ +--- +# vars file for apigee-time-sync