First working version of haproxy Docker
This commit is contained in:
parent
f70a3f36f1
commit
3fdb11f093
7
Vagrantfile
vendored
7
Vagrantfile
vendored
@ -29,6 +29,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
end
|
||||
|
||||
config.vm.define "solar-dev2" do |guest2|
|
||||
guest2.vm.provision "shell", inline: init_script, privileged: true
|
||||
guest2.vm.network "private_network", ip: "10.0.0.3"
|
||||
guest2.vm.host_name = "solar-dev2"
|
||||
|
||||
@ -39,6 +40,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
end
|
||||
|
||||
config.vm.define "solar-dev3" do |guest3|
|
||||
guest3.vm.provision "shell", inline: init_script, privileged: true
|
||||
guest3.vm.network "private_network", ip: "10.0.0.4"
|
||||
guest3.vm.host_name = "solar-dev3"
|
||||
|
||||
@ -49,6 +51,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
end
|
||||
|
||||
config.vm.define "solar-dev4" do |guest4|
|
||||
guest4.vm.provision "shell", inline: init_script, privileged: true
|
||||
guest4.vm.network "private_network", ip: "10.0.0.5"
|
||||
guest4.vm.host_name = "solar-dev4"
|
||||
|
||||
@ -59,6 +62,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
end
|
||||
|
||||
config.vm.define "solar-dev5" do |guest5|
|
||||
guest5.vm.provision "shell", inline: init_script, privileged: true
|
||||
guest5.vm.network "private_network", ip: "10.0.0.6"
|
||||
guest5.vm.host_name = "solar-dev5"
|
||||
|
||||
@ -69,8 +73,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
||||
end
|
||||
|
||||
config.vm.define "solar-dev6" do |guest6|
|
||||
guest6.vm.provision "shell", inline: init_script, privileged: true
|
||||
guest6.vm.network "private_network", ip: "10.0.0.7"
|
||||
guest6.vm.host_name = "solar-dev5"
|
||||
guest6.vm.host_name = "solar-dev6"
|
||||
|
||||
guest6.vm.provider :virtualbox do |v|
|
||||
v.customize ["modifyvm", :id, "--memory", 256]
|
||||
|
26
haproxy.cfg
Normal file
26
haproxy.cfg
Normal file
@ -0,0 +1,26 @@
|
||||
global
|
||||
log 127.0.0.1 local0
|
||||
log 127.0.0.1 local1 notice
|
||||
maxconn 4096
|
||||
tune.ssl.default-dh-param 2048
|
||||
pidfile /var/run/haproxy.pid
|
||||
user haproxy
|
||||
group haproxy
|
||||
daemon
|
||||
stats socket /var/run/haproxy.stats level admin
|
||||
ssl-default-bind-options no-sslv3
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
option redispatch
|
||||
option httplog
|
||||
option dontlognull
|
||||
option forwardfor
|
||||
timeout connect 5000
|
||||
timeout client 50000
|
||||
timeout server 50000
|
||||
frontend default_frontend
|
||||
bind 0.0.0.0:80
|
||||
default_backend default_service
|
||||
backend default_service
|
||||
balance roundrobin
|
@ -132,11 +132,11 @@ resources:
|
||||
model: x/resources/docker_container
|
||||
args:
|
||||
ip:
|
||||
image: haproxy
|
||||
image: tutum/haproxy
|
||||
ssh_user:
|
||||
ssh_key:
|
||||
host_binds:
|
||||
- /etc/haproxy: /vagrant/haproxy-etc
|
||||
- /etc/haproxy: /etc/haproxy
|
||||
volume_binds:
|
||||
|
||||
|
||||
|
@ -55,6 +55,8 @@ class TestHAProxyDeployment(unittest.TestCase):
|
||||
haproxy = db.get_resource('haproxy')
|
||||
|
||||
self.assertEqual(node5.args['ip'], haproxy.args['ip'])
|
||||
self.assertEqual(node5.args['ssh_key'], haproxy.args['ssh_key'])
|
||||
self.assertEqual(node5.args['ssh_user'], haproxy.args['ssh_user'])
|
||||
#self.assertItemsEqual(
|
||||
# haproxy.args['configs'],
|
||||
# {
|
||||
|
@ -2,5 +2,18 @@
|
||||
- hosts: [{{ ip }}]
|
||||
sudo: yes
|
||||
tasks:
|
||||
- shell: docker run -d --net="host" --privileged \
|
||||
--name {{ name }} {{ image }}
|
||||
- apt: name=python-pip state=present
|
||||
- shell: pip install docker-py
|
||||
- service: name=docker state=started
|
||||
- file: path=/etc/haproxy/haproxy.cfg state=touch
|
||||
- template: src=/vagrant/haproxy.cfg dest=/etc/haproxy/haproxy.cfg
|
||||
- docker:
|
||||
name: {{ name }}
|
||||
image: {{ image }}
|
||||
state: running
|
||||
volumes:
|
||||
{% for bind in host_binds %}
|
||||
{% for src, dst in bind.items () %}
|
||||
- {{ src }}:{{ dst }}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
@ -6,6 +6,8 @@ input:
|
||||
image:
|
||||
host_binds:
|
||||
volume_binds:
|
||||
ssh_user:
|
||||
ssh_key:
|
||||
input-types:
|
||||
host_binds: list
|
||||
volume_binds: list
|
||||
|
@ -4,5 +4,7 @@ version: 1.0.0
|
||||
input:
|
||||
ip:
|
||||
configs:
|
||||
ssh_user:
|
||||
ssh_key:
|
||||
input-types:
|
||||
configs: list
|
||||
|
Loading…
Reference in New Issue
Block a user