Add pre-network hook and example showing config-then-reboot
authorSteven Hardy <shardy@redhat.com>
Thu, 15 Dec 2016 10:09:35 +0000 (10:09 +0000)
committerSteven Hardy <shardy@redhat.com>
Thu, 15 Dec 2016 11:12:37 +0000 (11:12 +0000)
There are some requirements for early configuration that involves
e.g setting kernel parameters then rebooting.  Currently this can
be done via cloud-init, e.g firstboot templates, but there's been
discussion around enabling a SoftwareDeployment approach instead.

The main advantage of doing it this way is there's an error path
if something goes wrong with the config (except triggering the
reboot as we have to use NO_SIGNAL for that).

Change-Id: Ia54ee654f755631b8062eb5c209a60c6f9161500

extraconfig/pre_network/config_then_reboot.yaml [new file with mode: 0644]
overcloud-resource-registry-puppet.j2.yaml
puppet/blockstorage-role.yaml
puppet/cephstorage-role.yaml
puppet/compute-role.yaml
puppet/controller-role.yaml
puppet/objectstorage-role.yaml
puppet/role.role.j2.yaml

diff --git a/extraconfig/pre_network/config_then_reboot.yaml b/extraconfig/pre_network/config_then_reboot.yaml
new file mode 100644 (file)
index 0000000..ec4d276
--- /dev/null
@@ -0,0 +1,48 @@
+heat_template_version: 2014-10-16
+
+description: >
+  Do some configuration, then reboot - sometimes needed for early-boot
+  changes such as modifying kernel configuration
+
+parameters:
+  server:
+    type: string
+
+resources:
+
+  SomeConfig:
+    type: OS::Heat::SoftwareConfig
+    properties:
+      group: script
+      config: |
+        #!/bin/bash
+        echo "did some config before reboot" > /root/pre-reboot-config
+
+  SomeDeployment:
+    type: OS::Heat::SoftwareDeployment
+    properties:
+      name: SomeDeployment
+      server:  {get_param: server}
+      config: {get_resource: SomeConfig}
+      actions: ['CREATE'] # Only do this on CREATE
+
+  RebootConfig:
+    type: OS::Heat::SoftwareConfig
+    properties:
+      group: script
+      config: |
+        #!/bin/bash
+        # Stop os-collect-config to avoid any race collecting another
+        # deployment before reboot happens
+        systemctl stop os-collect-config.service
+        /sbin/reboot
+
+  RebootDeployment:
+    type: OS::Heat::SoftwareDeployment
+    depends_on: SomeDeployment
+    properties:
+      name: RebootDeployment
+      server:  {get_param: server}
+      config: {get_resource: RebootConfig}
+      actions: ['CREATE'] # Only do this on CREATE
+      signal_transport: NO_SIGNAL
index 77a4865..26fb317 100644 (file)
@@ -11,6 +11,7 @@ resource_registry:
   OS::TripleO::Tasks::PackageUpdate: extraconfig/tasks/yum_update.yaml
 
 {% for role in roles %}
+  OS::TripleO::{{role.name}}::PreNetworkConfig: OS::Heat::None
   OS::TripleO::{{role.name}}PostDeploySteps: puppet/post.yaml
   OS::TripleO::{{role.name}}: puppet/{{role.name.lower()}}-role.yaml
   OS::TripleO::{{role.name}}Config: puppet/{{role.name.lower()}}-config.yaml
index 36587a4..80f855a 100644 (file)
@@ -307,8 +307,14 @@ resources:
             - - {get_attr: [BlockStorage, name]}
               - ctlplane
 
+  PreNetworkConfig:
+    type: OS::TripleO::BlockStorage::PreNetworkConfig
+    properties:
+      server: {get_resource: BlockStorage}
+
   NetworkDeployment:
     type: OS::TripleO::SoftwareDeployment
+    depends_on: PreNetworkConfig
     properties:
       name: NetworkDeployment
       config: {get_resource: NetworkConfig}
index 558f97d..139fe7a 100644 (file)
@@ -313,8 +313,14 @@ resources:
             - - {get_attr: [CephStorage, name]}
               - ctlplane
 
+  PreNetworkConfig:
+    type: OS::TripleO::CephStorage::PreNetworkConfig
+    properties:
+      server: {get_resource: CephStorage}
+
   NetworkDeployment:
     type: OS::TripleO::SoftwareDeployment
+    depends_on: PreNetworkConfig
     properties:
       name: NetworkDeployment
       config: {get_resource: NetworkConfig}
index 818f18c..e906238 100644 (file)
@@ -316,6 +316,11 @@ resources:
             - - {get_attr: [NovaCompute, name]}
               - ctlplane
 
+  PreNetworkConfig:
+    type: OS::TripleO::Compute::PreNetworkConfig
+    properties:
+      server: {get_resource: NovaCompute}
+
   NetworkConfig:
     type: OS::TripleO::Compute::Net::SoftwareConfig
     properties:
@@ -329,6 +334,7 @@ resources:
 
   NetworkDeployment:
     type: OS::TripleO::SoftwareDeployment
+    depends_on: PreNetworkConfig
     properties:
       name: NetworkDeployment
       config: {get_resource: NetworkConfig}
index 2781daa..ecb298e 100644 (file)
@@ -335,6 +335,11 @@ resources:
             - - {get_attr: [Controller, name]}
               - ctlplane
 
+  PreNetworkConfig:
+    type: OS::TripleO::Controller::PreNetworkConfig
+    properties:
+      server: {get_resource: Controller}
+
   NetworkConfig:
     type: OS::TripleO::Controller::Net::SoftwareConfig
     properties:
@@ -348,6 +353,7 @@ resources:
 
   NetworkDeployment:
     type: OS::TripleO::SoftwareDeployment
+    depends_on: PreNetworkConfig
     properties:
       name: NetworkDeployment
       config: {get_resource: NetworkConfig}
index 2c76492..a592f60 100644 (file)
@@ -307,8 +307,14 @@ resources:
             - - {get_attr: [SwiftStorage, name]}
               - ctlplane
 
+  PreNetworkConfig:
+    type: OS::TripleO::ObjectStorage::PreNetworkConfig
+    properties:
+      server: {get_resource: SwiftStorage}
+
   NetworkDeployment:
     type: OS::TripleO::SoftwareDeployment
+    depends_on: PreNetworkConfig
     properties:
       name: NetworkDeployment
       config: {get_resource: NetworkConfig}
index 9726d97..522d858 100644 (file)
@@ -325,8 +325,14 @@ resources:
             - - {get_attr: [{{role}}, name]}
               - ctlplane
 
+  PreNetworkConfig:
+    type: OS::TripleO::{{role}}::PreNetworkConfig
+    properties:
+      server: {get_resource: {{role}}}}
+
   NetworkDeployment:
     type: OS::TripleO::SoftwareDeployment
+    depends_on: PreNetworkConfig
     properties:
       name: NetworkDeployment
       config: {get_resource: NetworkConfig}