Skip to content

Commit aeac41b

Browse files
committed
DevOps - Provisoinning
1 parent 94b3eaf commit aeac41b

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

Vagrantfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
hosts = {
2+
"dev" => "192.168.1.50",
3+
"pre" => "192.168.1.51"
4+
}
5+
6+
Vagrant.configure(2) do |config|
7+
config.vm.box = "ubuntu/vivid64"
8+
config.ssh.insert_key = false
9+
hosts.each do |name, ip|
10+
config.vm.define name do |vm|
11+
vm.vm.hostname = "%s" % name
12+
# vm.vm.network "private_network", ip: ip
13+
vm.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)", ip: ip
14+
vm.vm.provider "virtualbox" do |v|
15+
v.name = name
16+
end
17+
vm.vm.provision "shell", path: "provisioning.sh"
18+
end
19+
end
20+
end

postProvisioning.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# Install Docker Machine
3+
#curl -L https://github.com/docker/machine/releases/download/v0.4.0/docker-machine_linux-amd64 | sudo tee /usr/local/bin/docker-machine > /dev/null
4+
#sudo chmod u+x /usr/local/bin/docker-machine
5+
6+
# Install Firewall
7+
sudo apt-get install -y ufw
8+
yes | sudo ufw reset
9+
# Deny everything else
10+
sudo ufw default deny incoming
11+
# Allow outgoing traffic (for logs, updates, ...)
12+
sudo ufw default allow outgoing
13+
# Allow SSH
14+
sudo ufw allow ssh
15+
# Allow HTTP and WS
16+
sudo ufw allow 80/tcp
17+
# Allow HTTPS and WSS
18+
sudo ufw allow 443/tcp
19+
# Allow Docker daemon port and forwarding policy
20+
sudo ufw allow 2376/tcp
21+
#sudo sed -i -e "s/^DEFAULT_FORWARD_POLICY=\"DROP\"/DEFAULT_FORWARD_POLICY=\"ACCEPT\"/" /etc/default/ufw
22+
# Enable and reload
23+
yes | sudo ufw enable
24+
sudo ufw reload

provisioning.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
# Overriding bad Systemd default in Docker startup script
3+
sudo mkdir -p /etc/systemd/system/docker.service.d
4+
echo -e '[Service]\n# workaround to include default options\nEnvironmentFile=-/etc/default/docker\nExecStart=\nExecStart=/usr/bin/docker -d -H fd:// $DOCKER_OPTS' | sudo tee /etc/systemd/system/docker.service.d/ubuntu.conf
5+
# Set Docker daemon with the following properties:
6+
# * Daemon listen to external request and is exposed on port 2376, the default Docker port.
7+
# * Docker uses the AUFS driver for file storage.
8+
# * Daemon uses Docker's provided certification chain.
9+
# * Dameon has a generic label.
10+
# * Daemon is able to resolve DNS query using Google's DNS.
11+
echo 'DOCKER_OPTS="-H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=generic --dns 8.8.8.8 --dns 8.8.4.4"' | sudo tee /etc/default/docker
12+
sudo systemctl daemon-reload
13+
sudo systemctl restart docker
14+
# Enable Docker on server reboot
15+
sudo systemctl enable docker
16+
# Remove and clean unused packages
17+
sudo apt-get autoremove -y
18+
sudo apt-get autoclean -y

0 commit comments

Comments
 (0)