Merge "docker: add logging(source & groups)" into stable/pike
[apex-tripleo-heat-templates.git] / docker / services / pacemaker / cinder-backup.yaml
index d15c920..46b9932 100644 (file)
@@ -4,17 +4,11 @@ description: >
   OpenStack containerized Cinder Backup service
 
 parameters:
-  DockerNamespace:
-    description: namespace
-    default: 'tripleoupstream'
-    type: string
   DockerCinderBackupImage:
     description: image
-    default: 'centos-binary-cinder-backup:latest'
     type: string
   DockerCinderConfigImage:
     description: The container image to use for the cinder config_volume
-    default: 'centos-binary-cinder-api:latest'
     type: string
   CinderBackupBackend:
     default: swift
@@ -33,6 +27,10 @@ parameters:
     description: Mapping of service endpoint -> protocol. Typically set
                  via parameter_defaults in the resource registry.
     type: json
+  ServiceData:
+    default: {}
+    description: Dictionary packing service data
+    type: json
   ServiceNetMap:
     default: {}
     description: Mapping of service_name -> network name. Typically set
@@ -54,10 +52,14 @@ parameters:
 
 resources:
 
+  MySQLClient:
+    type: ../../../puppet/services/database/mysql-client.yaml
+
   CinderBackupBase:
     type: ../../../puppet/services/cinder-backup.yaml
     properties:
       EndpointMap: {get_param: EndpointMap}
+      ServiceData: {get_param: ServiceData}
       ServiceNetMap: {get_param: ServiceNetMap}
       DefaultPasswords: {get_param: DefaultPasswords}
       RoleName: {get_param: RoleName}
@@ -74,23 +76,29 @@ outputs:
       config_settings:
         map_merge:
           - get_attr: [CinderBackupBase, role_data, config_settings]
-          - tripleo::profile::pacemaker::cinder::backup_bundle::cinder_backup_docker_image: &cinder_backup_image
+          - tripleo::profile::pacemaker::cinder::backup_bundle::cinder_backup_docker_image: &cinder_backup_image_pcmklatest
               list_join:
-                - '/'
-                - [ {get_param: DockerNamespace}, {get_param: DockerCinderBackupImage} ]
+                - ':'
+                - - yaql:
+                      data: {get_param: DockerCinderBackupImage}
+                      expression: $.data.rightSplit(separator => ":", maxSplits => 1)[0]
+                  - 'pcmklatest'
             cinder::backup::manage_service: false
             cinder::backup::enabled: false
+      logging_source: {get_attr: [CinderBackupBase, role_data, logging_source]}
+      logging_groups: {get_attr: [CinderBackupBase, role_data, logging_groups]}
       step_config: ""
       service_config_settings: {get_attr: [CinderBackupBase, role_data, service_config_settings]}
       # BEGIN DOCKER SETTINGS
       puppet_config:
         config_volume: cinder
         puppet_tags: cinder_config,file,concat,file_line
-        step_config: {get_attr: [CinderBackupBase, role_data, step_config]}
-        config_image:
+        step_config:
           list_join:
-            - '/'
-            - [ {get_param: DockerNamespace}, {get_param: DockerCinderConfigImage} ]
+            - "\n"
+            - - {get_attr: [CinderBackupBase, role_data, step_config]}
+              - {get_attr: [MySQLClient, role_data, step_config]}
+        config_image: {get_param: DockerCinderConfigImage}
       kolla_config:
         /var/lib/kolla/config_files/cinder_backup.json:
           command: /usr/bin/cinder-backup --config-file /usr/share/cinder/cinder-dist.conf --config-file /etc/cinder/cinder.conf
@@ -102,10 +110,33 @@ outputs:
               owner: cinder:cinder
               recurse: true
       docker_config:
+        step_1:
+          cinder_backup_image_tag:
+            start_order: 1
+            detach: false
+            net: host
+            user: root
+            command:
+              - '/bin/bash'
+              - '-c'
+              - str_replace:
+                  template:
+                    "/usr/bin/docker tag 'CINDERBACKUP_IMAGE' 'CINDERBACKUP_IMAGE_PCMKLATEST'"
+                  params:
+                    CINDERBACKUP_IMAGE: {get_param: DockerCinderBackupImage}
+                    CINDERBACKUP_IMAGE_PCMKLATEST: *cinder_backup_image_pcmklatest
+            image: {get_param: DockerCinderBackupImage}
+            volumes:
+              - /etc/hosts:/etc/hosts:ro
+              - /etc/localtime:/etc/localtime:ro
+              - /dev/shm:/dev/shm:rw
+              - /etc/sysconfig/docker:/etc/sysconfig/docker:ro
+              - /usr/bin:/usr/bin:ro
+              - /var/run/docker.sock:/var/run/docker.sock:rw
         step_3:
           cinder_backup_init_logs:
             start_order: 0
-            image: *cinder_backup_image
+            image: {get_param: DockerCinderBackupImage}
             privileged: false
             user: root
             volumes:
@@ -129,7 +160,7 @@ outputs:
                   params:
                     TAGS: 'pacemaker::resource::bundle,pacemaker::property,pacemaker::constraint::location'
                     CONFIG: 'include ::tripleo::profile::base::pacemaker;include ::tripleo::profile::pacemaker::cinder::backup_bundle'
-            image: *cinder_backup_image
+            image: {get_param: DockerCinderBackupImage}
             volumes:
               - /etc/hosts:/etc/hosts:ro
               - /etc/localtime:/etc/localtime:ro
@@ -146,6 +177,33 @@ outputs:
             - /var/lib/cinder
             - /var/log/containers/cinder
       upgrade_tasks:
-        - name: Stop and disable cinder_backup service
+        - name: get bootstrap nodeid
+          tags: common
+          command: hiera -c /etc/puppet/hiera.yaml bootstrap_nodeid
+          register: bootstrap_node
+        - name: set is_bootstrap_node fact
+          tags: common
+          set_fact: is_bootstrap_node={{bootstrap_node.stdout|lower == ansible_hostname|lower}}
+        - name: Disable the openstack-cinder-backup cluster resource
+          tags: step2
+          pacemaker_resource:
+            resource: openstack-cinder-backup
+            state: disable
+            wait_for_resource: true
+          register: output
+          retries: 5
+          until: output.rc == 0
+          when: is_bootstrap_node
+        - name: Delete the stopped openstack-cinder-backup cluster resource.
+          tags: step2
+          pacemaker_resource:
+            resource: openstack-cinder-backup
+            state: delete
+            wait_for_resource: true
+          register: output
+          retries: 5
+          until: output.rc == 0
+          when: is_bootstrap_node
+        - name: Disable cinder_backup service
           tags: step2
-          service: name=openstack-cinder-backup state=stopped enabled=no
+          service: name=openstack-cinder-backup enabled=no