From d13163ab5165a314ea956c841155616fa305ee62 Mon Sep 17 00:00:00 2001 From: Paul Bourke Date: Fri, 14 Aug 2015 13:26:04 +0000 Subject: [PATCH] Add Ansible role for memcached Note, this is not in the inventories/site.yml as it will be a transparent dependency of Swift. Change-Id: Ic8c80072596594e646ece74ac0ce74c7000398ff Partitially-Implements: blueprint ansible-swift --- ansible/group_vars/all.yml | 2 ++ ansible/inventory/all-in-one | 3 +++ ansible/inventory/multinode | 3 +++ ansible/roles/memcached/defaults/main.yml | 9 +++++++++ ansible/roles/memcached/tasks/config.yml | 11 +++++++++++ ansible/roles/memcached/tasks/main.yml | 4 ++++ ansible/roles/memcached/tasks/start.yml | 19 +++++++++++++++++++ .../memcached/templates/memcached.conf.j2 | 1 + docker/common/memcached/config-external.sh | 6 +++--- docker/common/memcached/start.sh | 4 +++- 10 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 ansible/roles/memcached/defaults/main.yml create mode 100644 ansible/roles/memcached/tasks/config.yml create mode 100644 ansible/roles/memcached/tasks/main.yml create mode 100644 ansible/roles/memcached/tasks/start.yml create mode 100644 ansible/roles/memcached/templates/memcached.conf.j2 diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 1773b299e5..b316aff0d9 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -89,6 +89,8 @@ neutron_server_port: "9696" cinder_api_port: "8776" +memcached_port: "11211" + #################### # Openstack options diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one index a23958aa17..48886a9b11 100644 --- a/ansible/inventory/all-in-one +++ b/ansible/inventory/all-in-one @@ -38,6 +38,9 @@ network [cinder:children] control +[memcached:children] +control + # Additional control implemented here. These groups allow you to control which # services run on which hosts at a per-service level. diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode index 025edcea23..cd8f2fae09 100644 --- a/ansible/inventory/multinode +++ b/ansible/inventory/multinode @@ -44,6 +44,9 @@ network [cinder:children] control +[memcached:children] +control + # Additional control implemented here. These groups allow you to control which # services run on which hosts at a per-service level. diff --git a/ansible/roles/memcached/defaults/main.yml b/ansible/roles/memcached/defaults/main.yml new file mode 100644 index 0000000000..9c219d4fbc --- /dev/null +++ b/ansible/roles/memcached/defaults/main.yml @@ -0,0 +1,9 @@ +--- +project_name: "memcached" + +#################### +# Docker +#################### +memcached_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-memcached" +memcached_tag: "{{ openstack_release }}" +memcached_image_full: "{{ memcached_image }}:{{ memcached_tag }}" diff --git a/ansible/roles/memcached/tasks/config.yml b/ansible/roles/memcached/tasks/config.yml new file mode 100644 index 0000000000..27e2c97668 --- /dev/null +++ b/ansible/roles/memcached/tasks/config.yml @@ -0,0 +1,11 @@ +--- +- name: Ensuring config directory exists + file: + path: "{{ node_config_directory }}/memcached/" + state: "directory" + recurse: "yes" + +- name: Copying over config(s) + template: + src: "memcached.conf.j2" + dest: "{{ node_config_directory }}/memcached/memcached.conf" diff --git a/ansible/roles/memcached/tasks/main.yml b/ansible/roles/memcached/tasks/main.yml new file mode 100644 index 0000000000..1f16915ad9 --- /dev/null +++ b/ansible/roles/memcached/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- include: config.yml + +- include: start.yml diff --git a/ansible/roles/memcached/tasks/start.yml b/ansible/roles/memcached/tasks/start.yml new file mode 100644 index 0000000000..1c9c68ddcf --- /dev/null +++ b/ansible/roles/memcached/tasks/start.yml @@ -0,0 +1,19 @@ +--- +- name: Starting memcached container + docker: + docker_api_version: "{{ docker_api_version }}" + net: host + pull: "{{ docker_pull_policy }}" + restart_policy: "{{ docker_restart_policy }}" + restart_policy_retry: "{{ docker_restart_policy_retry }}" + state: reloaded + registry: "{{ docker_registry }}" + username: "{{ docker_registry_username }}" + password: "{{ docker_registry_password }}" + insecure_registry: "{{ docker_insecure_registry }}" + name: memcached + image: "{{ memcached_image_full }}" + volumes: "{{ node_config_directory }}/memcached/:/opt/kolla/memcached/:ro" + env: + KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" + when: inventory_hostname in groups['memcached'] diff --git a/ansible/roles/memcached/templates/memcached.conf.j2 b/ansible/roles/memcached/templates/memcached.conf.j2 new file mode 100644 index 0000000000..e08061f6dd --- /dev/null +++ b/ansible/roles/memcached/templates/memcached.conf.j2 @@ -0,0 +1 @@ +OPTIONS="-l {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} -p {{ memcached_port }}" diff --git a/docker/common/memcached/config-external.sh b/docker/common/memcached/config-external.sh index ab9593896e..0f3fa83361 100644 --- a/docker/common/memcached/config-external.sh +++ b/docker/common/memcached/config-external.sh @@ -1,7 +1,7 @@ #!/bin/bash -SOURCE="/opt/kolla/memcached/memcached" -TARGET="/etc/sysconfig/memcached" -OWNER="swift" +SOURCE="/opt/kolla/memcached/memcached.conf" +TARGET="/etc/memcached.conf" +OWNER="memcached" if [[ -f "$SOURCE" ]]; then cp $SOURCE $TARGET diff --git a/docker/common/memcached/start.sh b/docker/common/memcached/start.sh index 2d69b41b7a..531dd38726 100755 --- a/docker/common/memcached/start.sh +++ b/docker/common/memcached/start.sh @@ -11,4 +11,6 @@ source /opt/kolla/kolla-common.sh # Execute config strategy set_configs -exec $CMD $ARGS +source /etc/memcached.conf + +exec $CMD $ARGS $OPTIONS