diff --git a/ansible/roles/swift/defaults/main.yml b/ansible/roles/swift/defaults/main.yml index 6e156a8f39..b5d33691c4 100644 --- a/ansible/roles/swift/defaults/main.yml +++ b/ansible/roles/swift/defaults/main.yml @@ -40,6 +40,10 @@ swift_object_updater_image: "{{ docker_registry ~ '/' if docker_registry else '' swift_object_updater_tag: "{{ openstack_release }}" swift_object_updater_image_full: "{{ swift_object_updater_image }}:{{ swift_object_updater_tag }}" +swift_rsyncd_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-swift-rsyncd" +swift_rsyncd_tag: "{{ openstack_release }}" +swift_rsyncd_image_full: "{{ swift_rsyncd_image }}:{{ swift_rsyncd_tag }}" + #################### # Openstack #################### diff --git a/ansible/roles/swift/tasks/config.yml b/ansible/roles/swift/tasks/config.yml index b3ec2f1db7..6cec5f3f96 100644 --- a/ansible/roles/swift/tasks/config.yml +++ b/ansible/roles/swift/tasks/config.yml @@ -82,3 +82,14 @@ dest: "{{ node_config_directory }}/swift/container.ring.gz" } - { src: "/etc/kolla/config/swift/account.ring.gz", dest: "{{ node_config_directory }}/swift/account.ring.gz" } + +- name: Ensuring swift-rsyncd config directory exists + file: + path: "{{ node_config_directory }}/swift-rsyncd/" + state: "directory" + recurse: "yes" + +- name: Copying over swift-rsyncd config(s) + template: + src: "rsyncd.conf.j2" + dest: "{{ node_config_directory }}/swift-rsyncd/rsyncd.conf" diff --git a/ansible/roles/swift/tasks/start.yml b/ansible/roles/swift/tasks/start.yml index eaf9c9a6cd..854c4076b5 100644 --- a/ansible/roles/swift/tasks/start.yml +++ b/ansible/roles/swift/tasks/start.yml @@ -1,4 +1,24 @@ --- +- name: Starting Swift-rsyncd 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: swift_rsyncd + image: "{{ swift_rsyncd_image_full }}" + volumes: "{{ node_config_directory }}/swift-rsyncd/:/opt/kolla/swift-rsyncd/:ro" + volumes_from: + - swift_data + env: + KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" + - name: Starting Swift Proxy Server container docker: docker_api_version: "{{ docker_api_version }}" diff --git a/ansible/roles/swift/templates/rsyncd.conf.j2 b/ansible/roles/swift/templates/rsyncd.conf.j2 new file mode 100644 index 0000000000..38a40b1098 --- /dev/null +++ b/ansible/roles/swift/templates/rsyncd.conf.j2 @@ -0,0 +1,27 @@ +uid = swift +gid = swift +address = {{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }} + +{% if inventory_hostname in groups['swift-account-server'] %} +[account] +max connections = 2 +path = {{ swift_devices_mount_point }} +read only = false +lock file = /var/lock/account.lock +{% endif %} + +{% if inventory_hostname in groups['swift-container-server'] %} +[container] +max connections = 4 +path = {{ swift_devices_mount_point }} +read only = false +lock file = /var/lock/container.lock +{% endif %} + +{% if inventory_hostname in groups['swift-object-server'] %} +[object] +max connections = 8 +path = {{ swift_devices_mount_point }} +read only = false +lock file = /var/lock/object.lock +{% endif %} diff --git a/docker/swift/swift-rsyncd/Dockerfile.j2 b/docker/swift/swift-rsyncd/Dockerfile.j2 new file mode 100644 index 0000000000..b2f60a94ef --- /dev/null +++ b/docker/swift/swift-rsyncd/Dockerfile.j2 @@ -0,0 +1,22 @@ +FROM {{ namespace }}/{{ base_distro }}-{{ install_type }}-swift-base:{{ tag }} +MAINTAINER Kolla Project (https://launchpad.net/kolla) + +{% if base_distro in ['fedora', 'centos', 'oraclelinux'] %} + +RUN yum install -y rsync \ + && yum clean all + +{% elif base_distro in ['ubuntu', 'debian'] %} + +RUN apt-get install -y --no-install-recommends \ + rsync \ + && apt-get clean + +{% endif %} + +COPY start.sh / +COPY config-external.sh /opt/kolla/ + +CMD ["/start.sh"] + +{{ include_footer }} diff --git a/docker/swift/swift-rsyncd/config-external.sh b/docker/swift/swift-rsyncd/config-external.sh new file mode 100644 index 0000000000..3b3104272e --- /dev/null +++ b/docker/swift/swift-rsyncd/config-external.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +OWNER="swift" + +if [[ -f "/opt/kolla/swift-rsyncd/rsyncd.conf" ]]; then + cp /opt/kolla/swift-rsyncd/rsyncd.conf /etc/rsyncd.conf + chown ${OWNER}: /etc/rsyncd.conf + chmod 0640 /etc/rsyncd.conf +fi diff --git a/docker/swift/swift-rsyncd/start.sh b/docker/swift/swift-rsyncd/start.sh new file mode 100755 index 0000000000..2267bb59f3 --- /dev/null +++ b/docker/swift/swift-rsyncd/start.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -o errexit + +CMD="/usr/bin/rsync" +ARGS="--daemon --no-detach --config=/etc/rsyncd.conf" + +# Loading common functions. +source /opt/kolla/kolla-common.sh + +# Execute config strategy +set_configs + +exec $CMD $ARGS