Sesame HTTP: Deploy Splash Load Clusters in Batches

Install Ansible:

Go to the official document: http://www.ansible.com.cn/index.html

Seems like this host doesn't support Windows? Let's install Ubuntu on the virtual machine.

Less gossip and gossip directly to the dry goods:

The overall directory is as follows:


study@study:~/文档/ansible-examples$ tree Splash_Load_balancing_cluster
Splash_Load_balancing_cluster
├── group_vars
│   └── all
├── roles
│   ├── common
│   │   ├── files
│   │   │   ├── CentOS-Base.repo
│   │   │   ├── docker-ce.repo
El │ │ ├── epel.repo
│   │   │   ├── ntp.conf
P │ │ └── RPM-GPG-KEY-EPEL-7
│   │   ├── tasks
│ │ │ └── main.yml
│   │   └── templates
│   ├── docker
│   │   ├── handlers
│ │ │ └── main.yml
│   │   ├── tasks
│ │ │ └── main.yml
│   │   └── templates
│   │       └── daemon.json.j2
│   ├── haproxy
│   │   ├── handlers
│ │ │ └── main.yml
│   │   ├── tasks
│ │ │ └── main.yml
│   │   └── templates
│   │       └── haproxy.cfg.j2
│   └── splash
│       ├── files
│       │   ├── filters
│       │   │   └── default.txt
│       │   ├── js-profiles
│       │   ├── lua_modules
│       │   └── proxy-profiles
proxy.ini
│       └── tasks
│ └── main.yml
├── site.retry
└── site.yml

 Group_vars: Defines variables used globally

Roles: store all rules directory

Roles/common : All servers initialize configuration deployment

Roles/common/filters : files or folders to be used

Roles/common/task: deployment task (main.yml must have for entry)

Roles/common/templates : Configuration templates (jinja2 template syntax is used for changeable configuration files to get variables defined in Group_vars)

Roles/Docker : Docker installation configuration

Roles/HAproxy : Load balancing configuration for HAproxy

Roles/Splash : Image pull configuration deployment and startup of Splash

site.yml : startup entry

Instructions:

Define the host grouping in your Inventory file:

Must include HaProxy, and Docker two groups as follows:

study@study:~/文档/ansible-examples$ cat /etc/ansible/inventory/splash
[docker]
1.1.1.1
[haproxy]
10.253.20.25
 
[splash_ports]

 Create a new SSH key on the master and publish it to all the hosts you need to configure! ! ! ! (It must be noted that if the current working user of the machine does not exist on the remote host, the remote_user parameter needs to be specified):

study@study:~/文档/ansible-examples$ cat /etc/ansible/ansible.cfg
[defaults]
inventory= /etc/ansible/inventory/
 
remote_user=root

 Ok, start executing:

study@study:~/文档/ansible-examples/Splash_Load_balancing_cluster$ ansible-playbook site.yml

 The effect is like this:



PLAY [all] **********************************************************************************************************************************************************************************
 
TASK [Gathering Facts] **********************************************************************************************************************************************************************
ok: [10.1.4.101]
ok: [10.1.4.100]
 
TASK [common : Copy the CentOS repository definition] ***************************************************************************************************************************************
ok: [10.1.4.100]
ok: [10.1.4.101]
 
TASK [common : Copy the Docker repository definition] ***************************************************************************************************************************************
ok: [10.1.4.100]
ok: [10.1.4.101]
 
TASK [common : Create the repository for EPEL] **********************************************************************************************************************************************
ok: [10.1.4.100]
ok: [10.1.4.101]
 
TASK [common : Create the GPG key for EPEL] *************************************************************************************************************************************************
ok: [10.1.4.100]
ok: [10.1.4.101]
 
TASK [common : Firewalld service stop] ******************************************************************************************************************************************************
ok: [10.1.4.100]
ok: [10.1.4.101]
 
TASK [common : Chronyd service stop] ********************************************************************************************************************************************************
ok: [10.1.4.100]
ok: [10.1.4.101]
 
TASK [common : Install Ansible Base package] ************************************************************************************************************************************************
ok: [10.1.4.100] => (item=['libselinux-python', 'libsemanage-python', 'ntp'])
ok: [10.1.4.101] => (item=['libselinux-python', 'libsemanage-python', 'ntp'])
 
TASK [common : Configure SELinux to disable] ************************************************************************************************************************************************
 [WARNING]: SELinux state change will take effect next reboot
 
ok: [10.1.4.100]
ok: [10.1.4.101]
 
TASK [common : Change TimeZone] *************************************************************************************************************************************************************
ok: [10.1.4.100]
ok: [10.1.4.101]
 
TASK [common : Copy NTP conf] ***************************************************************************************************************************************************************
ok: [10.1.4.100]
ok: [10.1.4.101]
 
TASK [common : NTP Start] *******************************************************************************************************************************************************************
ok: [10.1.4.100]
ok: [10.1.4.101]
 
PLAY [docker] *******************************************************************************************************************************************************************************
 
TASK [Gathering Facts] **********************************************************************************************************************************************************************
ok: [10.1.4.101]
 
TASK [docker : Install Docker package] ******************************************************************************************************************************************************
ok: [10.1.4.101] => (item=['yum-utils', 'device-mapper-persistent-data', 'lvm2', 'docker-ce'])
 
TASK [docker : Start Docker] ****************************************************************************************************************************************************************
ok: [10.1.4.101]
 
TASK [docker : Create Docker Speed Configuration file] **************************************************************************************************************************************
ok: [10.1.4.101]
 
TASK [docker : Restart Docker] **************************************************************************************************************************************************************
changed: [10.1.4.101]
 
TASK [splash : pull splash] *****************************************************************************************************************************************************************
changed: [10.1.4.101]
 
TASK [splash : Copy Splash module] **********************************************************************************************************************************************************
ok: [10.1.4.101] => (item=filters)
ok: [10.1.4.101] => (item=js-profiles)
ok: [10.1.4.101] => (item=lua_modules)
ok: [10.1.4.101] => (item=proxy-profiles)
 

 Just wait for the run and you can use it happily! If you need to add nodes, you can directly load the IP into the Docker group and execute it again!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326316792&siteId=291194637