From 15f3e8d5221a1391387d434285a64ef853024ccb Mon Sep 17 00:00:00 2001 From: Igor Gajsin Date: Fri, 23 Sep 2016 17:41:52 +0300 Subject: [PATCH] prevent to execute unnecessary tasks when redeploy Change-Id: I8c61f9a207016a8a867062fa250f5b89749d2add --- .../puppet/manifests/db-sync.pp | 27 +++++++++++++++++++ .../puppet/manifests/start_controller.pp | 22 +++++++-------- .../puppet/manifests/start_data.pp | 15 ++++++----- .../puppet/manifests/start_share.pp | 15 ++++++----- deployment_tasks.yaml | 19 ++++++++++--- gen_keys.sh | 7 +++++ gen_password.sh | 18 ++++++++----- 7 files changed, 87 insertions(+), 36 deletions(-) create mode 100644 deployment_scripts/puppet/manifests/db-sync.pp create mode 100644 gen_keys.sh diff --git a/deployment_scripts/puppet/manifests/db-sync.pp b/deployment_scripts/puppet/manifests/db-sync.pp new file mode 100644 index 0000000..9d3c154 --- /dev/null +++ b/deployment_scripts/puppet/manifests/db-sync.pp @@ -0,0 +1,27 @@ +# Copyright 2016 Mirantis, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +notify {'MODULAR: fuel-plugin-manila/db-sync': } + +$manila = hiera_hash('manila', {}) +$db_pass = $manila['db_password'] +$db_host = hiera('database_vip') +$req = 'select name from availability_zones\G' + +exec { 'manual_db_sync': + command => 'manila-manage db sync', + path => '/usr/bin:/bin', + user => 'manila', + unless => "mysql -u manila -p${db_pass} -h ${db_host} -e \"${req}\" manila | grep nova" +} diff --git a/deployment_scripts/puppet/manifests/start_controller.pp b/deployment_scripts/puppet/manifests/start_controller.pp index 6e4f4b4..39ce677 100644 --- a/deployment_scripts/puppet/manifests/start_controller.pp +++ b/deployment_scripts/puppet/manifests/start_controller.pp @@ -25,21 +25,19 @@ $inits = { create_resources('::manila_auxiliary::initd', $inits) -exec { 'manual_db_sync': - command => 'manila-manage db sync', - path => '/usr/bin', - user => 'manila', - }-> - +notify {'Restart manila-api': + }~> service { 'manila-api': ensure => 'running', name => 'manila-api', enable => true, hasstatus => true, }-> - service { 'manila-scheduler': - ensure => 'running', - name => 'manila-scheduler', - enable => true, - hasstatus => true, - } + notify {' Restart manila-scheduler': + }~> + service { 'manila-scheduler': + ensure => 'running', + name => 'manila-scheduler', + enable => true, + hasstatus => true, + } diff --git a/deployment_scripts/puppet/manifests/start_data.pp b/deployment_scripts/puppet/manifests/start_data.pp index dd035a7..51bc7c1 100644 --- a/deployment_scripts/puppet/manifests/start_data.pp +++ b/deployment_scripts/puppet/manifests/start_data.pp @@ -23,10 +23,11 @@ $inits = { create_resources('::manila_auxiliary::initd', $inits) - -service { 'manila-data': - ensure => 'running', - name => 'manila-data', - enable => true, - hasstatus => true, -} +notify {'Restart manila-data': + }~> + service { 'manila-data': + ensure => 'running', + name => 'manila-data', + enable => true, + hasstatus => true, + } diff --git a/deployment_scripts/puppet/manifests/start_share.pp b/deployment_scripts/puppet/manifests/start_share.pp index a2e3ff8..e7f97b1 100644 --- a/deployment_scripts/puppet/manifests/start_share.pp +++ b/deployment_scripts/puppet/manifests/start_share.pp @@ -61,10 +61,11 @@ $inits = { create_resources('::manila_auxiliary::initd', $inits) - -service { 'manila-share': - ensure => 'running', - name => 'manila-share', - enable => true, - hasstatus => true, -} +notify {'Restart manila-share': + }~> + service { 'manila-share': + ensure => 'running', + name => 'manila-share', + enable => true, + hasstatus => true, + } diff --git a/deployment_tasks.yaml b/deployment_tasks.yaml index 55f752e..b3cd1b8 100644 --- a/deployment_tasks.yaml +++ b/deployment_tasks.yaml @@ -4,7 +4,7 @@ - id: manila-share type: group role: [manila-share] - tasks: [hiera, globals, setup_repositories, tools, logging, netconfig, firewall, hosts, ntp-client, dns-client, cgroups, deploy_start] + tasks: [hiera, globals, setup_repositories, tools, logging, netconfig, firewall, hosts, ntp-client, dns-client, cgroups, manila-hiera, deploy_start] required_for: [deploy_end] requires: [deploy_start, primary-controller] parameters: @@ -16,7 +16,7 @@ - id: manila-data type: group role: [manila-data] - tasks: [hiera, globals, setup_repositories, tools, logging, netconfig, firewall, hosts, ntp-client, dns-client, cgroups, deploy_start] + tasks: [hiera, globals, setup_repositories, tools, logging, netconfig, firewall, hosts, ntp-client, dns-client, cgroups, manila-hiera, deploy_start] required_for: [deploy_end] requires: [deploy_start, primary-controller] parameters: @@ -32,7 +32,7 @@ requires: [pre_deployment_start] required_for: [manila-copy_keys] parameters: - cmd: sh /etc/puppet/modules/osnailyfacter/modular/astute/generate_keys.sh -p /var/lib/fuel/keys/ -i {CLUSTER_ID} -s 'manila' + cmd: sh /var/www/nailgun/plugins/fuel-plugin-manila-1.0/gen_keys.sh {CLUSTER_ID} timeout: 180 - id: manila-copy_keys @@ -200,11 +200,24 @@ puppet_modules: "puppet/modules:/etc/puppet/modules" timeout: 3600 +- id: manila-db-sync + type: puppet + groups: [primary-controller] + version: 2.1.0 + requires: [manila-main, manila-db] + required_for: [manila-controller-start] + parameters: + puppet_manifest: "puppet/manifests/db-sync.pp" + puppet_modules: "puppet/modules:/etc/puppet/modules" + timeout: 3600 + - id: manila-controller-start type: puppet groups: [primary-controller, controller] version: 2.1.0 requires: [manila-main] + cross-depends: + - name: manila-db-sync parameters: puppet_manifest: "puppet/manifests/start_controller.pp" puppet_modules: "puppet/modules:/etc/puppet/modules" diff --git a/gen_keys.sh b/gen_keys.sh new file mode 100644 index 0000000..6711b56 --- /dev/null +++ b/gen_keys.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +CLUSTER_ID=$1 + +if [ ! -d /var/lib/fuel/keys/$CLUSTER_ID/manila ]; then + sh /etc/puppet/modules/osnailyfacter/modular/astute/generate_keys.sh -p /var/lib/fuel/keys/ -i $CLUSTER_ID -s 'manila' +fi diff --git a/gen_password.sh b/gen_password.sh index 61ed8e9..b07fc2e 100644 --- a/gen_password.sh +++ b/gen_password.sh @@ -1,15 +1,18 @@ #!/bin/sh CLUSTER_ID=$1 +PLUGIN_YAML=/etc/fuel/cluster/$CLUSTER_ID/fuel-plugin-manila.yaml -gen_pass() { - openssl rand -base64 32|tr -d '=' -} +if [ ! -f $PLUGIN_YAML ]; then -user_pass=$(gen_pass) -maniladb_pass=$(gen_pass) + gen_pass() { + openssl rand -base64 32|tr -d '=' + } -echo " + user_pass=$(gen_pass) + maniladb_pass=$(gen_pass) + + echo " --- manila: user_password: $user_pass @@ -23,4 +26,5 @@ echo " min_ram: \"256\" os_name: ubuntu public: \"true\" -" > /etc/fuel/cluster/$CLUSTER_ID/fuel-plugin-manila.yaml +" > $PLUGIN_YAML +fi