Running Salt Minion In Docker Container From Scratch
In this post, we will install salt minion in docker container and configure the public IP so it will be reachable from outside.
Prerequisites:
- Ubuntu host up and running.
- Public IP should be configured.
- Docker should be installed.
PULL UBUNTU DOCKER IMAGE
$ docker pull ubuntu:14.04.5 |
---|
It will download the Ubuntu docker image.
Create a container for salt minion
$ docker run -ti --name salt-minion-agent --net=none --privileged=true ubuntu:14.04.5 bash |
---|
This will create a container, we will use the same container to install salt minion. Now configure the network for this container.
ASSIGNING AN IP FOR A CONTAINER
Here I am assuming that host machine is having interface "eth0" with public IP configured. Name of the container is salt-minion-agent. The below steps needs to be performed on the docker host.
Create a virtual interface
$ ip link add name veth0 link eth0 type macvlan mode bridge New virtual interface "veth0" will be created.Get the process id for the salt master container
$ docker inspect -f '{{.State.Pid}}' salt-minion-agent Create Link
$ mkdir -p /var/run/netns $ ln -s /proc/<processid>/ns/net /var/run/netns/<processid>
Assign the virtual interface to salt-master
$ ip link set veth0 netns <processid> name eth0 Get the public Ip to virtual interface
$ docker exec -it salt-minion-agent dhclient -v eth0
Note: If you are facing any issue on assigning the static public IP to the container then check out this guide
Install salt minion on newly created container
Login into the container
$ docker attach salt-minion-agent Install Ubuntu basic packages
$ apt-get update
$ apt-get install software-properties-common$ apt-get install python-software-propertiesInstall salt master
$ add-apt-repository ppa:saltstack/salt
$ apt-get update
$ apt-get install salt-minion
Here we have added the salt stack ppa and installed the salt minion.
Edit the minion configuration file (/etc/salt/minion) and search for "master:" and update with the salt-master IP e.g. master: 10.10.98.90
Restart the salt-minion service
$ service salt-minion restart
You should have a salt minion configured. Now accept the salt minion key on the salt master.
Run below commands on the salt master
Verify an unaccepted key on the salt master
$ salt-key -L Accept the minion key
$ salt-key -A
Now you have successfully configured the salt-minion to salt-master.
Test the configuration by running below command, Result must me True.
Run the ping command
$ salt '*' test.ping
You should have a salt stack running on docker container.
Comments
Post a Comment