diff --git a/ansible/ansible-base/playbook.yml b/ansible/ansible-base/playbook.yml index 8257ee7..07e993a 100644 --- a/ansible/ansible-base/playbook.yml +++ b/ansible/ansible-base/playbook.yml @@ -1,11 +1,8 @@ --- - - hosts: all + - hosts: localhost + connection: local become: true roles: - packages - configs - - ssh - - hosts: playgs - roles: - - coding_vim diff --git a/ansible/ansible-base/roles/configs/tasks/main.yml b/ansible/ansible-base/roles/configs/tasks/main.yml index a42d4a0..726c896 100644 --- a/ansible/ansible-base/roles/configs/tasks/main.yml +++ b/ansible/ansible-base/roles/configs/tasks/main.yml @@ -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 diff --git a/maria-cluster/README.md b/maria-cluster/README.md new file mode 100644 index 0000000..ad78b22 --- /dev/null +++ b/maria-cluster/README.md @@ -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` + diff --git a/maria-cluster/ansible.cfg b/maria-cluster/ansible.cfg new file mode 100644 index 0000000..ba6efb0 --- /dev/null +++ b/maria-cluster/ansible.cfg @@ -0,0 +1,3 @@ +# ansible.cfg +[defaults] +inventory = inventory diff --git a/maria-cluster/install.yml b/maria-cluster/install.yml new file mode 100644 index 0000000..73e2007 --- /dev/null +++ b/maria-cluster/install.yml @@ -0,0 +1,9 @@ +--- + - name: Install packages + hosts: all + tasks: + - name: install + yum: + name: ['mariadb', 'mariadb-server'] + state: present + diff --git a/maria-cluster/inventory b/maria-cluster/inventory new file mode 100644 index 0000000..bde6cc9 --- /dev/null +++ b/maria-cluster/inventory @@ -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 diff --git a/maria-cluster/playbook.yml b/maria-cluster/playbook.yml new file mode 100644 index 0000000..63d573a --- /dev/null +++ b/maria-cluster/playbook.yml @@ -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 diff --git a/maria-cluster/roles/db/tasks/main.yml b/maria-cluster/roles/db/tasks/main.yml new file mode 100644 index 0000000..e69de29 diff --git a/maria-cluster/roles/ingress/tasks/main.yml b/maria-cluster/roles/ingress/tasks/main.yml new file mode 100644 index 0000000..b3312e3 --- /dev/null +++ b/maria-cluster/roles/ingress/tasks/main.yml @@ -0,0 +1,5 @@ +--- +- name: Install nginx light + apt: + name: 'nginx-light' + state: present diff --git a/maria-cluster/roles/php/tasks/main.yml b/maria-cluster/roles/php/tasks/main.yml new file mode 100644 index 0000000..8a96f54 --- /dev/null +++ b/maria-cluster/roles/php/tasks/main.yml @@ -0,0 +1,7 @@ +--- +- name: Install php-fpm and deps + apt: + name: ['php-fpm', 'php-mysql'] + state: present + update_cache: yes +