Maria cluster

This commit is contained in:
Lulzette 2021-12-06 20:33:53 +00:00
parent 8b1ac8796f
commit cbccbfd3e8
10 changed files with 152 additions and 10 deletions

View File

@ -1,11 +1,8 @@
---
- hosts: all
- hosts: localhost
connection: local
become: true
roles:
- packages
- configs
- ssh
- hosts: playgs
roles:
- coding_vim

View File

@ -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
View 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`

View File

@ -0,0 +1,3 @@
# ansible.cfg
[defaults]
inventory = inventory

View 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
View 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

View 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

View File

View File

@ -0,0 +1,5 @@
---
- name: Install nginx light
apt:
name: 'nginx-light'
state: present

View File

@ -0,0 +1,7 @@
---
- name: Install php-fpm and deps
apt:
name: ['php-fpm', 'php-mysql']
state: present
update_cache: yes