Saltstack [SOLVED]: How to use Packer Salt provisioner to create docker images?

Saltstack [SOLVED]: How to use Packer Salt provisioner to create docker images?

Home Forums Automation Tools Saltstack Tutorials Saltstack [SOLVED]: How to use Packer Salt provisioner to create docker images?

Tagged: ,

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #241093

    Cloudy Point
    Keymaster

    QuestionQuestion

    How to use Packer Salt provisioner to create docker images ?

    here is my packer.json file. I will comment inline below

    {
      "builders": [
        {
          "type": "docker",
          "image": "enonic/docker-salt-masterless-ubuntu",
          "export_path": "cassandra.tar" // Not sure what this is doing?
        }
      ],
      "provisioners": [
        {
          "type": "file",
          "source": "/srv/salt/cassandra", // This is where the cassandra directory is on my host machine which is ubuntu
          "destination": "/srv/salt/cassandra" // This is where I expect the cassandra directory on my host machine gets copied to inside a docker container
        },
        {
          "type": "salt-masterless",
          "local_state_tree": "/srv/salt/cassandra",
          "custom_state": "/srv/salt/cassandra/init.sls",
          "disable_sudo": true
        }
      ]
    }
    

    sudo docker build packer.json

    I get the following error

    Build 'docker' errored: Failed to upload to '/srv/salt/cassandra' in container: Error response from daemon: lstat /var/lib/docker/aufs/mnt/0c6a422400a073624a66b00580a6b9e5551e82a06495c46b1f840b38ca55699d/srv/salt: no such file or directory
    . exit status 1.
    
    ==> Some builds didn't complete successfully and had errors:
    --> docker: Failed to upload to '/srv/salt/cassandra' in container: Error response from daemon: lstat /var/lib/docker/aufs/mnt/0c6a422400a073624a66b00580a6b9e5551e82a06495c46b1f840b38ca55699d/srv/salt: no such file or directory
    

    It would be great if I can get a simple working example on how to use salt state files from host machine and build a docker image using packer. My cassandra state files are same as https://github.com/salt-formulas/salt-formula-cassandra

    My top.sls file looks like this

    base:
      'client*-es-*':
        - roles-elasticsearch
      'client*-cassandra-*':
        - roles-cassandra
    
    
      'P@os:(Debian|Ubuntu) and P@roles:(elasticsearch|cassandra)':
        - match: compound
        - deb-common
    
      'roles:elasticsearch':
        - match: grain
        - disk-raid0-3volumes
        - disk-elasticsearch
        - elasticsearch
        - elasticsearch.cerebro
      'roles:cassandra':
        - match: grain
        - disk-raid0-3volumes
        - disk-cassandra
        - cassandra
    

    I just want to build a docker container image only for cassandra but not for everything in my top.sls. so how do I do that?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.