mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Updated Ansible playbooks & docs for Ubuntu 16.04 deployment
This commit is contained in:
parent
375873b6ed
commit
b68557507f
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
If you didn't read the introduction to the [cloud deployment starter templates](index.html), please do that now. The main point is that they're not for deploying a production node; they can be used as a starting point.
|
If you didn't read the introduction to the [cloud deployment starter templates](index.html), please do that now. The main point is that they're not for deploying a production node; they can be used as a starting point.
|
||||||
|
|
||||||
This page explains how to use [Ansible](https://www.ansible.com/) to install, configure and run all the software needed to run a one-machine BigchainDB node on a server running Ubuntu 14.04.
|
This page explains how to use [Ansible](https://www.ansible.com/) to install, configure and run all the software needed to run a one-machine BigchainDB node on a server running Ubuntu 16.04.
|
||||||
|
|
||||||
|
|
||||||
## Install Ansible
|
## Install Ansible
|
||||||
|
|
||||||
The Ansible documentation has [installation instructions](https://docs.ansible.com/ansible/intro_installation.html). Note the control machine requirements: at the time of writing, Ansible required Python 2.6 or 2.7. (Support for Python 3 [is a goal of Ansible 2.2](https://github.com/ansible/ansible/issues/15976#issuecomment-221264089).)
|
The Ansible documentation has [installation instructions](https://docs.ansible.com/ansible/intro_installation.html). Note the control machine requirements: at the time of writing, Ansible required Python 2.6 or 2.7. ([Python 3 support is coming](https://docs.ansible.com/ansible/python_3_support.html): "Ansible 2.2 features a tech preview of Python 3 support." and the latest version, as of January 31, 2017, was 2.2.1.0. For now, it's probably best to use it with Python 2.)
|
||||||
|
|
||||||
For example, you could create a special Python 2.x virtualenv named `ansenv` and then install Ansible in it:
|
For example, you could create a special Python 2.x virtualenv named `ansenv` and then install Ansible in it:
|
||||||
```text
|
```text
|
||||||
@ -19,9 +19,9 @@ pip install ansible
|
|||||||
|
|
||||||
## About Our Example Ansible Playbook
|
## About Our Example Ansible Playbook
|
||||||
|
|
||||||
Our example Ansible playbook installs, configures and runs a basic BigchainDB node on an Ubuntu 14.04 machine. That playbook is in `.../bigchaindb/ntools/one-m/ansible/one-m-node.yml`.
|
Our example Ansible playbook installs, configures and runs a basic BigchainDB node on an Ubuntu 16.04 machine. That playbook is in `.../bigchaindb/ntools/one-m/ansible/one-m-node.yml`.
|
||||||
|
|
||||||
When you run the playbook (as per the instructions below), it ensures all the necessary software is installed, configured and running. It can be used to get a BigchainDB node set up on a bare Ubuntu 14.04 machine, but it can also be used to ensure that everything is okay on a running BigchainDB node. (If you run the playbook against a host where everything is okay, then it won't change anything on that host.)
|
When you run the playbook (as per the instructions below), it ensures all the necessary software is installed, configured and running. It can be used to get a BigchainDB node set up on a bare Ubuntu 16.04 machine, but it can also be used to ensure that everything is okay on a running BigchainDB node. (If you run the playbook against a host where everything is okay, then it won't change anything on that host.)
|
||||||
|
|
||||||
|
|
||||||
## Create an Ansible Inventory File
|
## Create an Ansible Inventory File
|
||||||
@ -39,7 +39,15 @@ echo "192.0.2.128" > hosts
|
|||||||
but replace `192.0.2.128` with the IP address of the host.
|
but replace `192.0.2.128` with the IP address of the host.
|
||||||
|
|
||||||
|
|
||||||
## Run the Ansible Playbook
|
## Run the Ansible Playbook(s)
|
||||||
|
|
||||||
|
The latest Ubuntu 16.04 AMIs from Canonical don't include Python 2 (which is required by Ansible), so the first step is to run a small Ansible playbook to install Python 2 on the managed node:
|
||||||
|
```text
|
||||||
|
# cd to the directory .../bigchaindb/ntools/one-m/ansible
|
||||||
|
ansible-playbook -i hosts --private-key ~/.ssh/<key-name> install-python2.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
where `<key-name>` should be replaced by the name of the SSH private key you created earlier (for SSHing to the host machine at your cloud hosting provider).
|
||||||
|
|
||||||
The next step is to run the Ansible playbook named `one-m-node.yml`:
|
The next step is to run the Ansible playbook named `one-m-node.yml`:
|
||||||
```text
|
```text
|
||||||
@ -47,14 +55,12 @@ The next step is to run the Ansible playbook named `one-m-node.yml`:
|
|||||||
ansible-playbook -i hosts --private-key ~/.ssh/<key-name> one-m-node.yml
|
ansible-playbook -i hosts --private-key ~/.ssh/<key-name> one-m-node.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
where `<key-name>` should be replaced by the name of the SSH private key you created earlier (for SSHing to the host machine at your cloud hosting provider).
|
|
||||||
|
|
||||||
What did you just do? Running that playbook ensures all the software necessary for a one-machine BigchainDB node is installed, configured, and running properly. You can run that playbook on a regular schedule to ensure that the system stays properly configured. If something is okay, it does nothing; it only takes action when something is not as-desired.
|
What did you just do? Running that playbook ensures all the software necessary for a one-machine BigchainDB node is installed, configured, and running properly. You can run that playbook on a regular schedule to ensure that the system stays properly configured. If something is okay, it does nothing; it only takes action when something is not as-desired.
|
||||||
|
|
||||||
|
|
||||||
## Some Notes on the One-Machine Node You Just Got Running
|
## Some Notes on the One-Machine Node You Just Got Running
|
||||||
|
|
||||||
* It ensures that the installed version of RethinkDB is `2.3.4~0trusty`. You can change that by changing the installation task.
|
* It ensures that the installed version of RethinkDB is the latest. You can change that by changing the installation task.
|
||||||
* It uses a very basic RethinkDB configuration file based on `bigchaindb/ntools/one-m/ansible/roles/rethinkdb/templates/rethinkdb.conf.j2`.
|
* It uses a very basic RethinkDB configuration file based on `bigchaindb/ntools/one-m/ansible/roles/rethinkdb/templates/rethinkdb.conf.j2`.
|
||||||
* If you edit the RethinkDB configuration file, then running the Ansible playbook will **not** restart RethinkDB for you. You must do that manually. (You can stop RethinkDB using `sudo /etc/init.d/rethinkdb stop`; run the playbook to get RethinkDB started again. This assumes you're using init.d, which is what the Ansible playbook assumes. If you want to use systemd, you'll have to edit the playbook accordingly, and stop RethinkDB using `sudo systemctl stop rethinkdb@<name_instance>`.)
|
* If you edit the RethinkDB configuration file, then running the Ansible playbook will **not** restart RethinkDB for you. You must do that manually. (You can stop RethinkDB using `sudo /etc/init.d/rethinkdb stop`; run the playbook to get RethinkDB started again. This assumes you're using init.d, which is what the Ansible playbook assumes. If you want to use systemd, you'll have to edit the playbook accordingly, and stop RethinkDB using `sudo systemctl stop rethinkdb@<name_instance>`.)
|
||||||
* It generates and uses a default BigchainDB configuration file, which it stores in `~/.bigchaindb` (the default location).
|
* It generates and uses a default BigchainDB configuration file, which it stores in `~/.bigchaindb` (the default location).
|
||||||
|
15
ntools/one-m/ansible/install-python2.yml
Normal file
15
ntools/one-m/ansible/install-python2.yml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
# This playbook ensures Python 2 is installed on the managed node.
|
||||||
|
# This is inspired by https://gist.github.com/gwillem/4ba393dceb55e5ae276a87300f6b8e6f
|
||||||
|
|
||||||
|
- hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
remote_user: ubuntu
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- name: Install Python 2
|
||||||
|
raw: test -e /usr/bin/python || (apt -y update && apt install -y python-minimal)
|
||||||
|
become: true
|
||||||
|
|
||||||
|
# action: setup will gather facts after python2 has been installed
|
||||||
|
- action: setup
|
@ -10,22 +10,24 @@
|
|||||||
apt: name={{item}} state=latest update_cache=yes
|
apt: name={{item}} state=latest update_cache=yes
|
||||||
become: true
|
become: true
|
||||||
with_items:
|
with_items:
|
||||||
|
- make
|
||||||
- git
|
- git
|
||||||
- g++
|
- g++
|
||||||
- python3-dev
|
|
||||||
- libffi-dev
|
- libffi-dev
|
||||||
- python3-setuptools # mainly for easy_install3, which is used to get latest pip3
|
- python3-dev
|
||||||
|
- python3-pip
|
||||||
# This should make both pip and pip3 be pip version >=8.1.2 (python 3.4).
|
- python3-setuptools
|
||||||
# See the comments about this below.
|
|
||||||
- name: Ensure the latest pip/pip3 is installed, using easy_install3
|
|
||||||
easy_install: executable=easy_install3 name=pip state=latest
|
|
||||||
become: true
|
|
||||||
|
|
||||||
- name: Ensure the latest setuptools (Python package) is installed
|
- name: Ensure the latest setuptools (Python package) is installed
|
||||||
pip: executable=pip3 name=setuptools state=latest
|
pip: executable=pip3 name=setuptools state=latest
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
# This should make both pip and pip3 be pip version >=8.1.2 (python 3.4).
|
||||||
|
# See the comments about this below.
|
||||||
|
#- name: Ensure the latest pip/pip3 is installed, using easy_install3
|
||||||
|
# easy_install: executable=easy_install3 name=pip state=latest
|
||||||
|
# become: true
|
||||||
|
|
||||||
- name: Install BigchainDB from PyPI using sudo pip3 install bigchaindb
|
- name: Install BigchainDB from PyPI using sudo pip3 install bigchaindb
|
||||||
pip: executable=pip3 name=bigchaindb state=latest
|
pip: executable=pip3 name=bigchaindb state=latest
|
||||||
become: true
|
become: true
|
||||||
|
@ -12,12 +12,14 @@
|
|||||||
# To better understand the /etc/fstab fields/columns, see:
|
# To better understand the /etc/fstab fields/columns, see:
|
||||||
# http://man7.org/linux/man-pages/man5/fstab.5.html
|
# http://man7.org/linux/man-pages/man5/fstab.5.html
|
||||||
# https://tinyurl.com/jmmsyon = the soure code of the mount module
|
# https://tinyurl.com/jmmsyon = the soure code of the mount module
|
||||||
|
# Note: It seems the "nobootwait" option is gone in Ubuntu 16.04. See
|
||||||
|
# https://askubuntu.com/questions/786928/ubuntu-16-04-fstab-fails-with-nobootwait
|
||||||
- name: Ensure /data dir exists and is mounted + update /etc/fstab
|
- name: Ensure /data dir exists and is mounted + update /etc/fstab
|
||||||
mount:
|
mount:
|
||||||
name=/data
|
name=/data
|
||||||
src=/dev/xvdp
|
src=/dev/xvdp
|
||||||
fstype=ext4
|
fstype=ext4
|
||||||
opts="defaults,nofail,nobootwait"
|
opts="defaults,nofail"
|
||||||
dump=0
|
dump=0
|
||||||
passno=2
|
passno=2
|
||||||
state=mounted
|
state=mounted
|
||||||
|
@ -2,11 +2,12 @@
|
|||||||
# ansible/roles/rethinkdb/tasks/main.yml
|
# ansible/roles/rethinkdb/tasks/main.yml
|
||||||
|
|
||||||
# Note: the .list extension will be added to the rethinkdb filename automatically
|
# Note: the .list extension will be added to the rethinkdb filename automatically
|
||||||
|
# Note: xenial is the $DISTRIB_CODENAME for Ubuntu 16.04
|
||||||
- name: >
|
- name: >
|
||||||
Ensure RethinkDB's APT repository for Ubuntu trusty is present
|
Ensure RethinkDB's APT repository for Ubuntu xenial is present
|
||||||
in /etc/apt/sources.list.d/rethinkdb.list
|
in /etc/apt/sources.list.d/rethinkdb.list
|
||||||
apt_repository:
|
apt_repository:
|
||||||
repo='deb http://download.rethinkdb.com/apt trusty main'
|
repo='deb http://download.rethinkdb.com/apt xenial main'
|
||||||
filename=rethinkdb
|
filename=rethinkdb
|
||||||
state=present
|
state=present
|
||||||
become: true
|
become: true
|
||||||
@ -15,8 +16,8 @@
|
|||||||
apt_key: url=http://download.rethinkdb.com/apt/pubkey.gpg state=present
|
apt_key: url=http://download.rethinkdb.com/apt/pubkey.gpg state=present
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Ensure the Ubuntu package rethinkdb 2.3.4~0trusty is installed
|
- name: Ensure the latest rethinkdb package is installed
|
||||||
apt: name=rethinkdb=2.3.4~0trusty state=present update_cache=yes
|
apt: name=rethinkdb state=latest update_cache=yes
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Ensure the /data directory's owner and group are both 'rethinkdb'
|
- name: Ensure the /data directory's owner and group are both 'rethinkdb'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user