split 'common' Ansible role into bcdb_base & ntp, modified those a bit

This commit is contained in:
troymc
2016-08-23 17:17:26 +02:00
parent 460e1c3fba
commit a5a6e8ad4d
7 changed files with 62 additions and 51 deletions

View File

@@ -1,9 +1,11 @@
---
# This playbook deploys a BigchainDB node in one machine (one-m).
- name: install + configure + start all software
- name: Ensure a one-machine BigchainDB node is configured properly
hosts: all
remote_user: ubuntu
roles:
- common
- bcdb_base
- ntp
# TODO: upgrade pip and setuptools, see https://github.com/bobbyrenwick/ansible-pip

View File

@@ -0,0 +1,25 @@
---
# ansible/roles/bcdb_base/tasks/main.yml
# Note: "become: true" basically means "become root user for this task" i.e. sudo <cmd>
# See https://docs.ansible.com/ansible/become.html
- name: Do the equivalent of "sudo apt-get update"
apt: update_cache=yes
become: true
- name: Configure all unpacked but unconfigured packages
shell: /usr/bin/dpkg --configure -a
become: true
- name: Attempt to correct a system with broken dependencies in place
shell: /usr/bin/apt-get -y -f install
become: true
- name: Ensure the LATEST git g++ python3-dev are installed
apt: name={{item}} state=latest
become: true
with_items:
- git
- g++
- python3-dev

View File

@@ -1,9 +0,0 @@
---
# ansible/roles/common/handlers/main.yml
# See http://docs.ansible.com/playbooks_intro.html for more information about handlers.
- name: restart ntp
service: name=ntpd state=restarted
#- name: restart iptables
# service: name=iptables state=restarted

View File

@@ -1,38 +0,0 @@
---
# ansible/roles/common/tasks/main.yml
# Note: "become: true" basically means "become root user for this task" i.e. sudo <cmd>
# See https://docs.ansible.com/ansible/become.html
- name: Do the equivalent of "sudo apt-get update"
apt: update_cache=yes
become: true
- name: Uninstall ntpdate (deprecated)
apt: name=ntpdate state=absent
become: true
tags: ntp
- name: Update all installed packages to their latest versions
apt: upgrade=dist
become: true
- name: Install ntp
apt: name=ntp state=latest update_cache=yes
become: true
tags: ntp
#- name: Configure ntp file
# template: src=ntp.conf.j2 dest=/etc/ntp.conf
# tags: ntp
# "restart ntp" is the name of a handler (in common/handlers/main.yml)
# notify: restart ntp
- name: Start the ntp service
service: name=ntp state=started enabled=yes
become: true
tags: ntp
#- name: test to see if selinux is running
# command: getenforce
# register: sestatus
# changed_when: false

View File

@@ -0,0 +1,5 @@
---
# ansible/roles/common/handlers/main.yml
- name: restart ntp
service: name=ntpd state=restarted

View File

@@ -0,0 +1,24 @@
---
# ansible/roles/ntp/tasks/main.yml
- name: Ensure ntpdate is not installed (and uninstall it if necessary)
apt: name=ntpdate state=absent
become: true
- name: Ensure the LATEST ntp is installed and do "sudo apt-get update"
apt: name=ntp state=latest update_cache=yes
become: true
- name: Retrieve facts about the file /etc/ntp.conf
stat: path=/etc/ntp.conf
register: ntp_conf_file
- name: Fail when /etc/ntp.conf doesn't exist
fail: msg="The NTP config file /etc/ntp.conf doesn't exist'"
when: ntp_conf_file.stat.exists == False
# For now, we assume the default /etc/ntp.conf file is okay
- name: Ensure the ntp service is now started and should start on boot (enabled=yes)
service: name=ntp state=started enabled=yes
become: true