summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHui Kang <kangh@us.ibm.com>2016-09-02 00:48:01 -0400
committerzhubingbing <1392607554@qq.com>2016-09-15 03:33:57 +0000
commita5b53f3a7006ee025dc65de99a3749035af79397 (patch)
tree7ec498236a31ea67584033b8eb8feb3b188a64e9
parent239cea0c487414e78918b7d542f3bc792c30358f (diff)
downloadkolla-a5b53f3a7006ee025dc65de99a3749035af79397.tar.gz
kolla-a5b53f3a7006ee025dc65de99a3749035af79397.zip
Add etcd ansible role
Change-Id: If8351ab3000006323a05924e907f1e3745768304 Co-Authored-By: zhubingbing <zhubingbing10@gmail.com>> Partially-implements: bp kuryr-docker-plugin
-rw-r--r--ansible/group_vars/all.yml4
-rw-r--r--ansible/inventory/all-in-one3
-rw-r--r--ansible/inventory/multinode3
-rw-r--r--ansible/roles/etcd/defaults/main.yml10
-rw-r--r--ansible/roles/etcd/meta/main.yml3
-rw-r--r--ansible/roles/etcd/tasks/bootstrap.yml18
-rw-r--r--ansible/roles/etcd/tasks/config.yml15
-rw-r--r--ansible/roles/etcd/tasks/deploy.yml6
-rw-r--r--ansible/roles/etcd/tasks/main.yml2
-rw-r--r--ansible/roles/etcd/tasks/pull.yml6
-rw-r--r--ansible/roles/etcd/tasks/reconfigure.yml1
-rw-r--r--ansible/roles/etcd/tasks/start.yml24
-rw-r--r--ansible/roles/etcd/tasks/upgrade.yml4
-rw-r--r--ansible/roles/etcd/templates/etcd.json.j23
-rw-r--r--ansible/site.yml7
-rw-r--r--docker/etcd/extend_start.sh8
-rw-r--r--etc/kolla/passwords.yml5
-rw-r--r--releasenotes/notes/etcd-docker-ansible-51baaa1322a0c5a8.yaml3
18 files changed, 125 insertions, 0 deletions
diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml
index 8dccd00e4..b0e5485fa 100644
--- a/ansible/group_vars/all.yml
+++ b/ansible/group_vars/all.yml
@@ -195,6 +195,9 @@ influxdb_http_port: "8086"
senlin_api_port: "8778"
+etcd_client_port: "2379"
+etcd_peer_port: "2380"
+
public_protocol: "{{ 'https' if kolla_enable_tls_external | bool else 'http' }}"
internal_protocol: "http"
admin_protocol: "http"
@@ -245,6 +248,7 @@ enable_cinder: "no"
enable_cinder_backend_lvm: "no"
enable_cloudkitty: "no"
enable_congress: "no"
+enable_etcd: "no"
enable_gnocchi: "no"
enable_grafana: "no"
enable_heat: "yes"
diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one
index d4c96d7da..a3be4315b 100644
--- a/ansible/inventory/all-in-one
+++ b/ansible/inventory/all-in-one
@@ -23,6 +23,9 @@ compute
[grafana:children]
monitoring
+[etcd:children]
+control
+
[kibana:children]
control
diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode
index f54341a15..542d8ecc3 100644
--- a/ansible/inventory/multinode
+++ b/ansible/inventory/multinode
@@ -41,6 +41,9 @@ compute
[grafana:children]
monitoring
+[etcd:children]
+control
+
[influxdb:children]
monitoring
diff --git a/ansible/roles/etcd/defaults/main.yml b/ansible/roles/etcd/defaults/main.yml
new file mode 100644
index 000000000..c8f73263a
--- /dev/null
+++ b/ansible/roles/etcd/defaults/main.yml
@@ -0,0 +1,10 @@
+---
+project_name: "etcd"
+
+
+####################
+# Docker
+####################
+etcd_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-etcd"
+etcd_tag: "{{ openstack_release }}"
+etcd_image_full: "{{ etcd_image }}:{{ etcd_tag }}"
diff --git a/ansible/roles/etcd/meta/main.yml b/ansible/roles/etcd/meta/main.yml
new file mode 100644
index 000000000..6b4fff8fe
--- /dev/null
+++ b/ansible/roles/etcd/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - { role: common }
diff --git a/ansible/roles/etcd/tasks/bootstrap.yml b/ansible/roles/etcd/tasks/bootstrap.yml
new file mode 100644
index 000000000..bea1cb7ec
--- /dev/null
+++ b/ansible/roles/etcd/tasks/bootstrap.yml
@@ -0,0 +1,18 @@
+---
+- name: Running etcd bootstrap container
+ kolla_docker:
+ action: "start_container"
+ common_options: "{{ docker_common_options }}"
+ detach: False
+ environment:
+ KOLLA_BOOTSTRAP:
+ KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
+ image: "{{ etcd_image_full }}"
+ labels:
+ BOOTSTRAP:
+ name: "bootstrap_etcd"
+ restart_policy: "never"
+ volumes:
+ - "{{ node_config_directory }}/etcd/:{{ container_config_directory }}/:ro"
+ - "kolla_etcd:/var/lib/etcd/"
+ - "kolla_logs:/var/log/kolla/"
diff --git a/ansible/roles/etcd/tasks/config.yml b/ansible/roles/etcd/tasks/config.yml
new file mode 100644
index 000000000..2ff3ac1f0
--- /dev/null
+++ b/ansible/roles/etcd/tasks/config.yml
@@ -0,0 +1,15 @@
+---
+- name: Ensuring config directories exist
+ file:
+ path: "{{ node_config_directory }}/{{ item }}"
+ state: "directory"
+ recurse: yes
+ with_items:
+ - "etcd"
+
+- name: Copying over config.json files for services
+ template:
+ src: "{{ item }}.json.j2"
+ dest: "{{ node_config_directory }}/{{ item }}/config.json"
+ with_items:
+ - "etcd"
diff --git a/ansible/roles/etcd/tasks/deploy.yml b/ansible/roles/etcd/tasks/deploy.yml
new file mode 100644
index 000000000..98daa4021
--- /dev/null
+++ b/ansible/roles/etcd/tasks/deploy.yml
@@ -0,0 +1,6 @@
+---
+- include: config.yml
+
+- include: bootstrap.yml
+
+- include: start.yml
diff --git a/ansible/roles/etcd/tasks/main.yml b/ansible/roles/etcd/tasks/main.yml
new file mode 100644
index 000000000..b017e8b4a
--- /dev/null
+++ b/ansible/roles/etcd/tasks/main.yml
@@ -0,0 +1,2 @@
+---
+- include: "{{ action }}.yml"
diff --git a/ansible/roles/etcd/tasks/pull.yml b/ansible/roles/etcd/tasks/pull.yml
new file mode 100644
index 000000000..57d5bdae5
--- /dev/null
+++ b/ansible/roles/etcd/tasks/pull.yml
@@ -0,0 +1,6 @@
+---
+- name: Pulling etcd image
+ kolla_docker:
+ action: "pull_image"
+ common_options: "{{ docker_common_options }}"
+ image: "{{ etcd_image_full }}"
diff --git a/ansible/roles/etcd/tasks/reconfigure.yml b/ansible/roles/etcd/tasks/reconfigure.yml
new file mode 100644
index 000000000..ed97d539c
--- /dev/null
+++ b/ansible/roles/etcd/tasks/reconfigure.yml
@@ -0,0 +1 @@
+---
diff --git a/ansible/roles/etcd/tasks/start.yml b/ansible/roles/etcd/tasks/start.yml
new file mode 100644
index 000000000..7546f8841
--- /dev/null
+++ b/ansible/roles/etcd/tasks/start.yml
@@ -0,0 +1,24 @@
+---
+- name: Starting etcd container
+ kolla_docker:
+ action: "start_container"
+ common_options: "{{ docker_common_options }}"
+ environment:
+ ETCD_DATA_DIR: "/var/lib/etcd"
+ ETCD_NAME: "{{ ansible_hostname }}"
+ ETCD_ADVERTISE_CLIENT_URLS: "{{ internal_protocol }}://{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}:{{ etcd_client_port }}"
+ ETCD_LISTEN_CLIENT_URLS: "{{ internal_protocol }}://{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}:{{ etcd_client_port }}"
+ ETCD_INITIAL_ADVERTISE_PEER_URLS: "{{ internal_protocol }}://{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}:{{ etcd_peer_port }}"
+ ETCD_LISTEN_PEER_URLS: "{{ internal_protocol }}://{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}:{{ etcd_peer_port }}"
+ ETCD_INITIAL_CLUSTER_TOKEN: "{{ etcd_cluster_token }}"
+ ETCD_INITIAL_CLUSTER: "{% for host in groups['etcd'] %}{{ hostvars[host]['ansible_hostname'] }}={{ internal_protocol }}://{{ hostvars[host]['ansible_' + api_interface]['ipv4']['address'] }}:{{ etcd_peer_port }}{% if not loop.last %},{% endif %}{% endfor %}"
+ ETCD_INITIAL_CLUSTER_STATE: "new"
+ ETCD_OUT_FILE: "/var/log/kolla/etcd/etcd.log"
+ KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
+ image: "{{ etcd_image_full }}"
+ name: "etcd"
+ volumes:
+ - "{{ node_config_directory }}/etcd/:{{ container_config_directory }}/:ro"
+ - "/etc/localtime:/etc/localtime:ro"
+ - "kolla_etcd:/var/lib/etcd/"
+ - "kolla_logs:/var/log/kolla/"
diff --git a/ansible/roles/etcd/tasks/upgrade.yml b/ansible/roles/etcd/tasks/upgrade.yml
new file mode 100644
index 000000000..1f16915ad
--- /dev/null
+++ b/ansible/roles/etcd/tasks/upgrade.yml
@@ -0,0 +1,4 @@
+---
+- include: config.yml
+
+- include: start.yml
diff --git a/ansible/roles/etcd/templates/etcd.json.j2 b/ansible/roles/etcd/templates/etcd.json.j2
new file mode 100644
index 000000000..3ea11fd90
--- /dev/null
+++ b/ansible/roles/etcd/templates/etcd.json.j2
@@ -0,0 +1,3 @@
+{
+ "command": "etcd"
+}
diff --git a/ansible/site.yml b/ansible/site.yml
index 9134db55c..9aee3ca33 100644
--- a/ansible/site.yml
+++ b/ansible/site.yml
@@ -94,6 +94,13 @@
tags: rabbitmq,
when: enable_rabbitmq | bool }
+- hosts: etcd
+ serial: '{{ "30%" if action == "upgrade" else "0" }}'
+ roles:
+ - { role: etcd,
+ tags: etcd,
+ when: enable_etcd | bool }
+
- hosts:
- keystone
serial: '{{ "30%" if action == "upgrade" else "0" }}'
diff --git a/docker/etcd/extend_start.sh b/docker/etcd/extend_start.sh
index 485ee8e2d..718de9ebb 100644
--- a/docker/etcd/extend_start.sh
+++ b/docker/etcd/extend_start.sh
@@ -1,5 +1,13 @@
#!/bin/bash
+# Create log directory, with appropriate permissions
+if [[ ! -d "/var/log/kolla/etcd" ]]; then
+ mkdir -p /var/log/kolla/etcd
+fi
+if [[ $(stat -c %a /var/log/kolla/etcd) != "755" ]]; then
+ chmod 755 /var/log/kolla/etcd
+fi
+
# Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
# of the KOLLA_BOOTSTRAP variable being set, including empty.
if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
diff --git a/etc/kolla/passwords.yml b/etc/kolla/passwords.yml
index 84b1b7786..0291a79d7 100644
--- a/etc/kolla/passwords.yml
+++ b/etc/kolla/passwords.yml
@@ -138,3 +138,8 @@ keepalived_password:
# Kibana options
####################
kibana_password:
+
+####################
+# etcd options
+####################
+etcd_cluster_token:
diff --git a/releasenotes/notes/etcd-docker-ansible-51baaa1322a0c5a8.yaml b/releasenotes/notes/etcd-docker-ansible-51baaa1322a0c5a8.yaml
new file mode 100644
index 000000000..d16085c22
--- /dev/null
+++ b/releasenotes/notes/etcd-docker-ansible-51baaa1322a0c5a8.yaml
@@ -0,0 +1,3 @@
+---
+features:
+ - Add etcd ansible role