Maria cluster
This commit is contained in:
parent
8b1ac8796f
commit
cbccbfd3e8
@ -1,11 +1,8 @@
|
||||
---
|
||||
- hosts: all
|
||||
- hosts: localhost
|
||||
connection: local
|
||||
become: true
|
||||
roles:
|
||||
- packages
|
||||
- configs
|
||||
- ssh
|
||||
|
||||
- hosts: playgs
|
||||
roles:
|
||||
- coding_vim
|
||||
|
@ -32,11 +32,11 @@
|
||||
dest: "{{ ansible_user_dir }}/.bashrc"
|
||||
when: not omb_flag.stat.exists
|
||||
|
||||
- name: Put omb config
|
||||
template:
|
||||
src: files/omb-bashrc
|
||||
dest: "{{ ansible_user_dir }}/.bashrc"
|
||||
when: omb_flag.stat.exists
|
||||
# - name: Put omb config
|
||||
#template:
|
||||
# src: files/omb-bashrc
|
||||
# dest: "{{ ansible_user_dir }}/.bashrc"
|
||||
#when: omb_flag.stat.exists
|
||||
|
||||
# FIXME: logout from shell
|
||||
# - name: Install OMB
|
||||
|
9
maria-cluster/README.md
Normal file
9
maria-cluster/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
Создает контейнеры из указанного inventory с указанными в нем же IPшниками
|
||||
|
||||
Source: https://dev.to/livioribeiro/using-lxd-and-ansible-to-simulate-infrastructure-2g8l
|
||||
|
||||
|
||||
# wp-php
|
||||
|
||||
Packages: `php-fpm php-mysql`
|
||||
|
3
maria-cluster/ansible.cfg
Normal file
3
maria-cluster/ansible.cfg
Normal file
@ -0,0 +1,3 @@
|
||||
# ansible.cfg
|
||||
[defaults]
|
||||
inventory = inventory
|
9
maria-cluster/install.yml
Normal file
9
maria-cluster/install.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: Install packages
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: install
|
||||
yum:
|
||||
name: ['mariadb', 'mariadb-server']
|
||||
state: present
|
||||
|
34
maria-cluster/inventory
Normal file
34
maria-cluster/inventory
Normal file
@ -0,0 +1,34 @@
|
||||
# inventory/hosts
|
||||
|
||||
[centos]
|
||||
wp-db1 ip_address=10.54.82.31
|
||||
wp-db2 ip_address=10.54.82.32
|
||||
wp-db3 ip_address=10.54.82.33
|
||||
wp-db4 ip_address=10.54.82.34
|
||||
|
||||
[ubuntu]
|
||||
wp-php1 ip_address=10.54.82.41
|
||||
wp-php2 ip_address=10.54.82.42
|
||||
|
||||
wp-ingress1 ip_address=10.54.82.51
|
||||
wp-ingress2 ip_address=10.54.82.52
|
||||
|
||||
[ingress]
|
||||
wp-ingress1
|
||||
wp-ingress2
|
||||
|
||||
[db]
|
||||
wp-db1
|
||||
wp-db2
|
||||
wp-db3
|
||||
wp-db4
|
||||
|
||||
[php]
|
||||
wp-php1
|
||||
wp-php2
|
||||
|
||||
[lxdnested]
|
||||
|
||||
[all:vars]
|
||||
ansible_connection=lxd
|
||||
ansible_python_interpreter=/usr/bin/python3
|
78
maria-cluster/playbook.yml
Normal file
78
maria-cluster/playbook.yml
Normal file
@ -0,0 +1,78 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
# run this task in the host
|
||||
connection: local
|
||||
tasks:
|
||||
- name: create containers cent
|
||||
# get all host names from inventory
|
||||
loop: "{{ groups['centos'] }}"
|
||||
# use lxd_container module from ansible to create containers
|
||||
lxd_container:
|
||||
# container name is the hostname
|
||||
name: "{{ item }}"
|
||||
state: started
|
||||
source:
|
||||
type: image
|
||||
mode: pull
|
||||
server: https://images.linuxcontainers.org
|
||||
protocol: simplestreams
|
||||
alias: centos/8-Stream/cloud
|
||||
config:
|
||||
# nomad clients need some privileges to be able to run docker containers
|
||||
security.nesting: "{{ 'true' if item in groups['lxdnested'] else 'false' }}"
|
||||
devices:
|
||||
# configure network interface
|
||||
eth0:
|
||||
type: nic
|
||||
nictype: bridged
|
||||
parent: lxdbr0
|
||||
# get ip address from inventory
|
||||
ipv4.address: "{{ hostvars[item].ip_address }}"
|
||||
# # uncomment if you installed lxd using snap
|
||||
# url: unix:/var/snap/lxd/common/lxd/unix.socket
|
||||
|
||||
- name: create containers ubuntu
|
||||
# get all host names from inventory
|
||||
loop: "{{ groups['ubuntu'] }}"
|
||||
# use lxd_container module from ansible to create containers
|
||||
lxd_container:
|
||||
# container name is the hostname
|
||||
name: "{{ item }}"
|
||||
state: started
|
||||
source:
|
||||
type: image
|
||||
mode: pull
|
||||
server: https://images.linuxcontainers.org
|
||||
protocol: simplestreams
|
||||
alias: ubuntu/bionic/amd64
|
||||
config:
|
||||
# nomad clients need some privileges to be able to run docker containers
|
||||
security.nesting: "{{ 'true' if item in groups['lxdnested'] else 'false' }}"
|
||||
devices:
|
||||
# configure network interface
|
||||
eth0:
|
||||
type: nic
|
||||
nictype: bridged
|
||||
parent: lxdbr0
|
||||
# get ip address from inventory
|
||||
ipv4.address: "{{ hostvars[item].ip_address }}"
|
||||
# # uncomment if you installed lxd using snap
|
||||
# url: unix:/var/snap/lxd/common/lxd/unix.socket
|
||||
|
||||
#- hosts: all
|
||||
# gather_facts: no
|
||||
# tasks:
|
||||
# - name: Install python
|
||||
# raw: test -e /usr/bin/python || (apt -y update && apt install -y python)
|
||||
|
||||
- hosts: db
|
||||
roles:
|
||||
- db
|
||||
|
||||
- hosts: php
|
||||
roles:
|
||||
- php
|
||||
|
||||
- hosts: ingress
|
||||
roles:
|
||||
- ingress
|
0
maria-cluster/roles/db/tasks/main.yml
Normal file
0
maria-cluster/roles/db/tasks/main.yml
Normal file
5
maria-cluster/roles/ingress/tasks/main.yml
Normal file
5
maria-cluster/roles/ingress/tasks/main.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Install nginx light
|
||||
apt:
|
||||
name: 'nginx-light'
|
||||
state: present
|
7
maria-cluster/roles/php/tasks/main.yml
Normal file
7
maria-cluster/roles/php/tasks/main.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
- name: Install php-fpm and deps
|
||||
apt:
|
||||
name: ['php-fpm', 'php-mysql']
|
||||
state: present
|
||||
update_cache: yes
|
||||
|
Loading…
Reference in New Issue
Block a user