Install rexray docker volume plugin with cloud-init

Hi I’m using terraform and openstack to launch RancherOs 1.0.3. Everything works perfect…

How can I install the rexray volume plugin during cloud-init?

The below wont work because we have to wait to run the command until after docker is initialized…

runcmd:

  • [“docker” “plugin” “install” “rexray/cinder” “CINDER_AUTHURL=http://controller:5000/v3/” “CINDER_USERNAME=xxxx” “CINDER_PASSWORD=xxxx” “CINDER_DOMAINNAME=default”]

The documentation suggests using /etc/rc.local:

write_files:
  - path: /etc/rc.local
    permissions: "0755"
    owner: root
    content: |
      #!/bin/bash
      wait-for-docker
      docker plugin install rexray/cinder \
        CINDER_AUTHURL=http://controller:5000/v3/ \
        CINDER_USERNAME=xxxx \
        CINDER_PASSWORD=xxxx \
        CINDER_DOMAINNAME=default

I haven’t tried this, so I don’t know if it would work. I’m currently using this mechanism to populate some data files before the services actually start (but I have a problem with mounting files that did not originally exist).