Is there an example on how to build docker image using salt provisioner for cassandra?

71 views
Skip to first unread message

kant kodali

unread,
Sep 17, 2017, 1:22:24 AM9/17/17
to Packer
Hi All,

Is there an example on how to build docker image using salt provisioner for cassandra using standard salt cassandra formula? I don't see any examples online of anything similar on how to do this. 

Thanks!



Alvaro Miranda Aguilera

unread,
Sep 18, 2017, 2:54:25 AM9/18/17
to packe...@googlegroups.com
Hello

you can build one once you get all the steps.

moving one step at the time, do you need any help for the packer + docker part ?

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/513ef6b1-7005-4bcd-bb60-2cfe4383567a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

kant kodali

unread,
Dec 9, 2017, 3:38:31 PM12/9/17
to Packer
Hi Alvaro,

I think I got that part ok(at least I am hoping). 

My packer.json is just this 

{

  "builders": [

    {

      "type": "docker",

      "image": "enonic/docker-salt-masterless-ubuntu",

      "export_path": "cassandra.tar"

    }

  ],

  "provisioners": [

    {

      "type": "salt-masterless",

      "local_state_tree": "/home/ubuntu/saltstack",

      "custom_state": "/home/ubuntu/saltstack/cassandra",

      "disable_sudo": true

    }

  ]

}


I just want to build a docker image using salt state files that are located in "/home/ubuntu/saltstack/cassandra". 

When I run packer build  packer.json. I get the following putput

docker output will be in this color.


==> docker: Creating a temporary directory for sharing data...

==> docker: Pulling Docker image: enonic/docker-salt-masterless-ubuntu

    docker: Using default tag: latest

    docker: latest: Pulling from enonic/docker-salt-masterless-ubuntu

    docker: a3ed95caeb02: Already exists

    docker: 831a6feb5ab2: Already exists

    docker: 9a80cf3dc0d4: Already exists

    docker: 0b7e0d746c2a: Already exists

    docker: caa529e47699: Already exists

    docker: cc3d786e1a1d: Already exists

    docker: a3ed95caeb02: Already exists

    docker: a3ed95caeb02: Already exists

    docker: 542bb8386cb7: Already exists

    docker: 85d9f5a7e4c4: Already exists

    docker: 8d957d809ea4: Already exists

    docker: 0b3aea992171: Already exists

    docker: 55d33ae09bd1: Already exists

    docker: 783a588e9033: Already exists

    docker: f5baec465fa6: Already exists

    docker: be1db5170aaa: Already exists

    docker: a3ed95caeb02: Already exists

    docker: a3ed95caeb02: Already exists

    docker: Digest: sha256:5a89f581b9e4360eebf3133c6611b68ca359d69f80edca3f0a7c091e859377c2

    docker: Status: Image is up to date for enonic/docker-salt-masterless-ubuntu:latest

==> docker: Starting docker container...

    docker: Run command: docker run -v /home/ubuntu/.packer.d/tmp/packer-docker794493932:/packer-files -d -i -t enonic/docker-salt-masterless-ubuntu /bin/bash

    docker: Container ID: cd0129f12041cf56cca6611b38548644a44b7faac86b6a22572a995aec14b463

==> docker: Provisioning with Salt...

    docker: Downloading saltstack bootstrap to /tmp/install_salt.sh

    docker: /bin/sh: 1: curl: not found

    docker: /bin/sh: 1: wget: not found

    docker: Installing Salt with command sh /tmp/install_salt.sh

    docker: sh: 0: Can't open /tmp/install_salt.sh

    docker: Creating remote temporary directory: /tmp/salt

    docker: Creating directory: /tmp/salt

    docker: Uploading local state tree: /home/ubuntu/saltstack

    docker: Creating directory: /tmp/salt/states

    docker: Removing directory: /srv/salt

    docker: Moving /tmp/salt/states to /srv/salt

    docker: Running: salt-call --local  state.sls /home/ubuntu/saltstack/cassandra --file-root=/srv/salt --pillar-root=/srv/pillar --retcode-passthrough -l info

    docker: [INFO    ] Found minion id from getfqdn(): cd0129f12041

    docker: [WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.

    docker: [WARNING ] Although 'dmidecode' was found in path, the current user cannot execute it. Grains output might not be accurate.

    docker: [INFO    ] Loading fresh modules for state activity

    docker: local:

    docker:     Data failed to compile:

    docker: ----------

    docker:     No matching sls found for '/home/ubuntu/saltstack/cassandra' in env 'base'

==> docker: Killing the container: cd0129f12041cf56cca6611b38548644a44b7faac86b6a22572a995aec14b463

Build 'docker' errored: Error executing salt-call: Bad exit status: 1


Thanks!


On Sunday, September 17, 2017 at 11:54:25 PM UTC-7, Alvaro Miranda Aguilera wrote:
Hello

you can build one once you get all the steps.

moving one step at the time, do you need any help for the packer + docker part ?
On Sun, Sep 17, 2017 at 7:22 AM, kant kodali <kant...@gmail.com> wrote:
Hi All,

Is there an example on how to build docker image using salt provisioner for cassandra using standard salt cassandra formula? I don't see any examples online of anything similar on how to do this. 

Thanks!



--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.



--
Alvaro

kant kodali

unread,
Dec 9, 2017, 3:50:54 PM12/9/17
to Packer
I am running packer build  packer.json on my host machine and I believe salt-call is executing inside the docker container so how does it pickup my cassandra state files located in host machine (as you can see the path I specified in my packer.json in my previous email)? What steps I need to do?

Thanks!

Alvaro Miranda Aguilera

unread,
Dec 10, 2017, 5:33:22 AM12/10/17
to packe...@googlegroups.com
you can mount the same folder in the docker or you can use a file provisioner to copy them

Alvaro.

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/73768f51-4cf9-4c08-9c60-8b2d186c0440%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

kant kodali

unread,
Dec 10, 2017, 3:39:28 PM12/10/17
to packe...@googlegroups.com
Can I see an example please?

You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/rtKGUPB6Cyk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAHqq0eyjEbcm2pONmp2rO0WDUzB%3DjNVxaKnrLc2NgpERxuz9rQ%40mail.gmail.com.

kant kodali

unread,
Dec 10, 2017, 4:03:42 PM12/10/17
to packe...@googlegroups.com
I tried the following 


{

  "builders": [

    {

      "type": "docker",

      "image": "enonic/docker-salt-masterless-ubuntu",

      "export_path": "cassandra.tar"

    }

  ],

  "provisioners": [

    {

      "type": "file",

      "source": "/srv/salt/cassandra",  // I moved cassandra directory to this location in host

      "destination": "/srv/salt/cassandra" // I was expecting this is the location inside container it will get copied too but didn't work

    },

    {

      "type": "salt-masterless",

      "local_state_tree": "/srv/salt/cassandra",

      "custom_state": "/srv/salt/cassandra/init.sls",

      "disable_sudo": true

    }

  ]

}


sudo packer build  packer.json


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.

kant kodali

unread,
Dec 10, 2017, 4:13:06 PM12/10/17
to packe...@googlegroups.com
Can anyone here provide a simple working example using my packer.json file in my previous email ? That would be super helpful since I can try running things myself and understand how things work underneath.


Rickard von Essen

unread,
Dec 11, 2017, 1:32:32 AM12/11/17
to packe...@googlegroups.com

kant kodali

unread,
Dec 11, 2017, 6:00:52 AM12/11/17
to packe...@googlegroups.com
Thanks Rickard! I used the following packer.json and it worked however I have couple questions

{

  "builders": [

    {

      "type": "docker",

      "image": "enonic/docker-salt-masterless-ubuntu",

      "export_path": "cassandra.tar"

    }

  ],

  "provisioners": [

    {

      "type": "salt-masterless",

      "local_state_tree": "/srv/salt",

      "custom_state": "cassandra-local",

      "skip_bootstrap": true,

      "disable_sudo": true

    }

  ]

}


What is export_path ? Why am I giving a tar directory? I thought when I run packer build packer.json it would build a docker image which I can use to spawn a container.

when I run packer build packer.json I get the following 

==> docker: Exporting the container

==> docker: Killing the container: b33b07f7f0ecf5026574d29ee28aed0f71659ae11955994ac27fca060c7e7c22

Build 'docker' finished.


I also get a  cassandra.tar which I am not sure how to use to spawn a container?


Rickard von Essen

unread,
Dec 11, 2017, 6:06:44 AM12/11/17
to packe...@googlegroups.com
I thought when I run packer build packer.json it would build a docker image which I can use to spawn a container.


kant kodali

unread,
Dec 11, 2017, 6:19:00 AM12/11/17
to packe...@googlegroups.com
got it ! I also included post-processors in my packer.json. however on start (ENTRYPOINT) of container it is not running cassandra. What else I need to do ? here is my packer.json file

{

  "builders": [

    {

      "type": "docker",

      "image": "enonic/docker-salt-masterless-ubuntu",

      "commit": "true"

    }

  ],

  "provisioners": [

    {

      "type": "salt-masterless",

      "local_state_tree": "/srv/salt",

      "custom_state": "cassandra-local",

      "skip_bootstrap": true,

      "disable_sudo": true

    }

  ],

  "post-processors": [

    [

      {

        "type": "docker-tag",

        "repository": "hello/cassandra-demo",

        "tag": "0.1"

      }

    ]

  ]

}


docker run -it hello/cassandra-demo:0.1 bash


root@696a0fde2469:/# cqlsh


Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})


So what is that I need to start cassandra on a startup?


Thanks!


Rickard von Essen

unread,
Dec 11, 2017, 8:11:25 AM12/11/17
to packe...@googlegroups.com
You misunderstand how Docker works. 

If you run:
docker run -it hello/cassandra-demo:0.1 bash
The only process running in the container is "bash" (ps aux)

I think the best advice is to take a step back and start with some tutorials or a book, etc. on Docker.

Reply all
Reply to author
Forward
0 new messages