From 57017b0acd0a55cc32c697beba54b6d3e4e37c4d Mon Sep 17 00:00:00 2001 From: Ryan Hallisey Date: Thu, 17 Sep 2015 14:58:02 -0400 Subject: [PATCH] Replace config-external with a JSON file for Cinder Partially-Implements: blueprint replace-config-external Change-Id: Ic247433290b51c9fb613d90e4a9a0f3d11526b35 --- ansible/roles/cinder/tasks/bootstrap.yml | 2 +- ansible/roles/cinder/tasks/config.yml | 24 +++++++++++++++++++ ansible/roles/cinder/tasks/start.yml | 8 +++---- .../roles/cinder/templates/cinder-api.json.j2 | 11 +++++++++ .../cinder/templates/cinder-backup.json.j2 | 11 +++++++++ .../cinder/templates/cinder-scheduler.json.j2 | 11 +++++++++ .../cinder/templates/cinder-volume.json.j2 | 11 +++++++++ docker/cinder/cinder-api/start.sh | 10 ++++---- docker/cinder/cinder-backup/start.sh | 10 ++++---- docker/cinder/cinder-scheduler/start.sh | 10 ++++---- docker/cinder/cinder-volume/start.sh | 10 ++++---- 11 files changed, 89 insertions(+), 29 deletions(-) create mode 100644 ansible/roles/cinder/templates/cinder-api.json.j2 create mode 100644 ansible/roles/cinder/templates/cinder-backup.json.j2 create mode 100644 ansible/roles/cinder/templates/cinder-scheduler.json.j2 create mode 100644 ansible/roles/cinder/templates/cinder-volume.json.j2 diff --git a/ansible/roles/cinder/tasks/bootstrap.yml b/ansible/roles/cinder/tasks/bootstrap.yml index 55269a17a1..3d1e633562 100644 --- a/ansible/roles/cinder/tasks/bootstrap.yml +++ b/ansible/roles/cinder/tasks/bootstrap.yml @@ -57,7 +57,7 @@ insecure_registry: "{{ docker_insecure_registry }}" name: bootstrap_cinder image: "{{ cinder_api_image_full }}" - volumes: "{{ node_config_directory }}/cinder-api/:/opt/kolla/cinder-api/:ro" + volumes: "{{ node_config_directory }}/cinder-api/:/opt/kolla/config_files/:ro" volumes_from: - cinder_data env: diff --git a/ansible/roles/cinder/tasks/config.yml b/ansible/roles/cinder/tasks/config.yml index 636f28b576..33fb085142 100644 --- a/ansible/roles/cinder/tasks/config.yml +++ b/ansible/roles/cinder/tasks/config.yml @@ -19,6 +19,12 @@ config_dest: "{{ node_config_directory }}/{{ service_name }}/cinder.conf" when: inventory_hostname in groups['cinder-api'] +- name: Copying Cinder API JSON configuration file + template: + src: "roles/cinder/templates/cinder-api.json.j2" + dest: "{{ node_config_directory }}/cinder-api/config.json" + when: inventory_hostname in groups['cinder-api'] + - include: ../../config.yml vars: service_name: "cinder-backup" @@ -39,6 +45,12 @@ config_dest: "{{ node_config_directory }}/{{ service_name }}/cinder.conf" when: inventory_hostname in groups['cinder-backup'] +- name: Copying Cinder Backup JSON configuration file + template: + src: "roles/cinder/templates/cinder-backup.json.j2" + dest: "{{ node_config_directory }}/cinder-backup/config.json" + when: inventory_hostname in groups['cinder-backup'] + - include: ../../config.yml vars: service_name: "cinder-scheduler" @@ -59,6 +71,12 @@ config_dest: "{{ node_config_directory }}/{{ service_name }}/cinder.conf" when: inventory_hostname in groups['cinder-scheduler'] +- name: Copying Cinder Scheduler JSON configuration file + template: + src: "roles/cinder/templates/cinder-scheduler.json.j2" + dest: "{{ node_config_directory }}/cinder-scheduler/config.json" + when: inventory_hostname in groups['cinder-scheduler'] + - include: ../../config.yml vars: service_name: "cinder-volume" @@ -78,3 +96,9 @@ - "{{ node_templates_directory }}/{{ service_name }}/{{ service_name }}.conf_augment" config_dest: "{{ node_config_directory }}/{{ service_name }}/cinder.conf" when: inventory_hostname in groups['cinder-volume'] + +- name: Copying Cinder Volume JSON configuration file + template: + src: "roles/cinder/templates/cinder-volume.json.j2" + dest: "{{ node_config_directory }}/cinder-volume/config.json" + when: inventory_hostname in groups['cinder-volume'] \ No newline at end of file diff --git a/ansible/roles/cinder/tasks/start.yml b/ansible/roles/cinder/tasks/start.yml index fac2a7d7d1..a55412c5e9 100644 --- a/ansible/roles/cinder/tasks/start.yml +++ b/ansible/roles/cinder/tasks/start.yml @@ -12,7 +12,7 @@ insecure_registry: "{{ docker_insecure_registry }}" name: cinder_api image: "{{ cinder_api_image_full }}" - volumes: "{{ node_config_directory }}/cinder-api/:/opt/kolla/cinder-api/:ro" + volumes: "{{ node_config_directory }}/cinder-api/:/opt/kolla/config_files/:ro" env: KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" when: inventory_hostname in groups['cinder-api'] @@ -31,7 +31,7 @@ insecure_registry: "{{ docker_insecure_registry }}" name: cinder_backup image: "{{ cinder_backup_image_full }}" - volumes: "{{ node_config_directory }}/cinder-backup/:/opt/kolla/cinder-backup/:ro" + volumes: "{{ node_config_directory }}/cinder-backup/:/opt/kolla/config_files/:ro" env: KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" when: inventory_hostname in groups['cinder-backup'] @@ -50,7 +50,7 @@ insecure_registry: "{{ docker_insecure_registry }}" name: cinder_scheduler image: "{{ cinder_scheduler_image_full }}" - volumes: "{{ node_config_directory }}/cinder-scheduler/:/opt/kolla/cinder-scheduler/:ro" + volumes: "{{ node_config_directory }}/cinder-scheduler/:/opt/kolla/config_files/:ro" env: KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" when: inventory_hostname in groups['cinder-scheduler'] @@ -70,7 +70,7 @@ privileged: True name: cinder_volume image: "{{ cinder_volume_image_full }}" - volumes: "{{ node_config_directory }}/cinder-volume/:/opt/kolla/cinder-volume/:ro" + volumes: "{{ node_config_directory }}/cinder-volume/:/opt/kolla/config_files/:ro" env: KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" when: inventory_hostname in groups['cinder-volume'] diff --git a/ansible/roles/cinder/templates/cinder-api.json.j2 b/ansible/roles/cinder/templates/cinder-api.json.j2 new file mode 100644 index 0000000000..44f3a0f592 --- /dev/null +++ b/ansible/roles/cinder/templates/cinder-api.json.j2 @@ -0,0 +1,11 @@ +{ + "command": "/usr/bin/cinder-api --config-file /etc/cinder/cinder.conf", + "config_files": [ + { + "source": "/opt/kolla/config_files/cinder.conf", + "dest": "/etc/cinder/cinder.conf", + "owner": "cinder", + "perm": "0600" + } + ] +} diff --git a/ansible/roles/cinder/templates/cinder-backup.json.j2 b/ansible/roles/cinder/templates/cinder-backup.json.j2 new file mode 100644 index 0000000000..bba9f718b3 --- /dev/null +++ b/ansible/roles/cinder/templates/cinder-backup.json.j2 @@ -0,0 +1,11 @@ +{ + "command": "/usr/bin/cinder-backup --config-file /etc/cinder/cinder.conf", + "config_files": [ + { + "source": "/opt/kolla/config_files/cinder.conf", + "dest": "/etc/cinder/cinder.conf", + "owner": "cinder", + "perm": "0600" + } + ] +} diff --git a/ansible/roles/cinder/templates/cinder-scheduler.json.j2 b/ansible/roles/cinder/templates/cinder-scheduler.json.j2 new file mode 100644 index 0000000000..2c7cb5f257 --- /dev/null +++ b/ansible/roles/cinder/templates/cinder-scheduler.json.j2 @@ -0,0 +1,11 @@ +{ + "command": "/usr/bin/cinder-scheduler --config-file /etc/cinder/cinder.conf", + "config_files": [ + { + "source": "/opt/kolla/config_files/cinder.conf", + "dest": "/etc/cinder/cinder.conf", + "owner": "cinder", + "perm": "0600" + } + ] +} diff --git a/ansible/roles/cinder/templates/cinder-volume.json.j2 b/ansible/roles/cinder/templates/cinder-volume.json.j2 new file mode 100644 index 0000000000..20dc6b5383 --- /dev/null +++ b/ansible/roles/cinder/templates/cinder-volume.json.j2 @@ -0,0 +1,11 @@ +{ + "command": "/usr/bin/cinder-volume --config-file /etc/cinder/cinder.conf", + "config_files": [ + { + "source": "/opt/kolla/config_files/cinder.conf", + "dest": "/etc/cinder/cinder.conf", + "owner": "cinder", + "perm": "0600" + } + ] +} diff --git a/docker/cinder/cinder-api/start.sh b/docker/cinder/cinder-api/start.sh index 6c61b3a4ec..2c6e3922fc 100755 --- a/docker/cinder/cinder-api/start.sh +++ b/docker/cinder/cinder-api/start.sh @@ -2,14 +2,12 @@ set -o errexit -CMD="/usr/bin/cinder-api" -ARGS="--config-file /etc/cinder/cinder.conf" - # Loading common functions. source /opt/kolla/kolla-common.sh -# Execute config strategy -set_configs +# Generate run command +python /opt/kolla/set_configs.py +CMD=$(cat /run_command) # Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases # of the KOLLA_BOOTSTRAP variable being set, including empty. @@ -18,4 +16,4 @@ if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then exit 0 fi -exec $CMD $ARGS +exec $CMD diff --git a/docker/cinder/cinder-backup/start.sh b/docker/cinder/cinder-backup/start.sh index 7d9403f076..bfa6c7878c 100755 --- a/docker/cinder/cinder-backup/start.sh +++ b/docker/cinder/cinder-backup/start.sh @@ -2,13 +2,11 @@ set -o errexit -CMD="/usr/bin/cinder-backup" -ARGS="--config-file /etc/cinder/cinder.conf" - # Loading common functions. source /opt/kolla/kolla-common.sh -# Execute config strategy -set_configs +# Generate run command +python /opt/kolla/set_configs.py +CMD=$(cat /run_command) -exec $CMD $ARGS +exec $CMD diff --git a/docker/cinder/cinder-scheduler/start.sh b/docker/cinder/cinder-scheduler/start.sh index 759175e3f9..bfa6c7878c 100755 --- a/docker/cinder/cinder-scheduler/start.sh +++ b/docker/cinder/cinder-scheduler/start.sh @@ -2,13 +2,11 @@ set -o errexit -CMD="/usr/bin/cinder-scheduler" -ARGS="--config-file /etc/cinder/cinder.conf" - # Loading common functions. source /opt/kolla/kolla-common.sh -# Execute config strategy -set_configs +# Generate run command +python /opt/kolla/set_configs.py +CMD=$(cat /run_command) -exec $CMD $ARGS +exec $CMD diff --git a/docker/cinder/cinder-volume/start.sh b/docker/cinder/cinder-volume/start.sh index a6874ce471..bfa6c7878c 100755 --- a/docker/cinder/cinder-volume/start.sh +++ b/docker/cinder/cinder-volume/start.sh @@ -2,13 +2,11 @@ set -o errexit -CMD="/usr/bin/cinder-volume" -ARGS="--config-file /etc/cinder/cinder.conf" - # Loading common functions. source /opt/kolla/kolla-common.sh -# Execute config strategy -set_configs +# Generate run command +python /opt/kolla/set_configs.py +CMD=$(cat /run_command) -exec $CMD $ARGS +exec $CMD