Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
joohanhong
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
JooHan Hong
joohanhong
Commits
8313fcbd
Commit
8313fcbd
authored
Mar 08, 2021
by
JooHan Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ansible, 2021-03-08, update11
parent
ac9a98d0
Pipeline
#5120
passed with stages
in 2 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
146 additions
and
1 deletion
+146
-1
README.md
ANSIBLE/DBMS/MariaDB/README.md
+132
-0
README.md
ANSIBLE/DBMS/README.md
+12
-0
README.md
ANSIBLE/README.md
+2
-1
No files found.
ANSIBLE/DBMS/MariaDB/README.md
0 → 100644
View file @
8313fcbd
[
![logo
](
https://www.hongsnet.net/images/logo.gif
)
](https://www.hongsnet.net)
# Ansible의 copy,file 모듈 및 jinja2 템플릿을 이용한 MariaDB 설치
> MariaDB 설치를 자동화 할 수 있다.
## 주요 기능
-
templates/resolv.conf.j2 파일을 이용해 변수에 맞게 DNS Resolver 설정을 수행할 수 있다.
-
DNS Resolver는 설정즉시 반영되기 때문에 설정 후 dig 명령을 통해 제대로 Resolving 되는 지 확인한다.
## Inventory 설정
```
bash
# cat hosts
[
ALL_HOSTS]
172.16.0.100
managed_ip
=
172.16.0.100
des
=
"2020-12-03"
[
ALL_HOSTS_OK]
```
대상 호스트는 172.16.0.100이며, 추가는 2020-12-03에 수행한다. 참고적으로
**ALL_HOSTS_OK**
호스트 그룹은 작업이 완료된 호스트의 history를 위한 그룹이다.
## Host Variables 설정
```
bash
# cat host_vars/172.16.0.100
ansible_ssh_host: 172.16.0.100
ansible_ssh_port: SSH_포트번호
ansible_ssh_user: 사용자 아이디
ansible_ssh_pass:
"사용자 패스워드"
ansible_become:
yes
ansible_become_method: su
ansible_become_user: root
ansible_become_pass:
"!root_패스워드"
ansible_python_interpreter: python2.7
```
## Playbook 설정
```python
---
-
name: Debian(Minimal Install) Basic APT Package Install
hosts: ALL_HOSTS
vars:
server_id: "XX"
buffer_pool_size: "65535MB"
mysql_conf_src: "/etc/mysql_src"
tasks:
-
name: Basic apt sources.list file Backup
command: cp -rf /etc/apt/sources.list /etc/apt/sources.list_src
when: sources_list_src is not exists
-
name: APT source sources.list file copy
copy:
src: "{{ item }}"
dest: /etc/apt/sources.list
owner: 'root'
group: 'root'
mode: 0644
#attr: i
with_items:
[
'sources.list'
]
-
name: MariaDB 10.3 Installing
apt:
pkg:
-
mariadb-server=10.3
-
name: MariaDB Basic Setting
command: cp -rfp /etc/mysql /etc/mysql_src
when: mysql_conf_src is not exists
-
name: MariaDB config files copy
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: 'root'
group: 'root'
with_items:
-
{ src: mysql_config/debian-start, dest: /etc/mysql/debian-start }
-
{ src: mysql_config/debian.cnf, dest: /etc/mysql/debian.cnf }
-
{ src: mysql_config/mariadb.cnf, dest: /etc/mysql/conf.d/mariadb.cnf }
-
{ src: mysql_config/mysqld_safe_syslog.cnf, dest: /etc/mysql/conf.d/mysqld_safe_syslog.cnf }
-
{ src: mysql_config/tokudb.cnf, dest: /etc/mysql/conf.d/tokudb.cnf }
-
name: mysql config files permission set
file:
path: "{{ item.path }}"
mode: "{{ item.mode }}"
with_items:
-
{ path: /etc/mysql/debian-start, mode: 755 }
-
{ path: /etc/mysql/debian.cnf, mode: 600 }
-
{ path: /etc/mysql/conf.d/mariadb.cnf, mode: 644 }
-
{ path: /etc/mysql/conf.d/mysqld_safe_syslog.cnf, mode: 644 }
-
{ path: /etc/mysql/conf.d/tokudb.cnf, mode: 644 }
-
name: ntp.conf configuration
template: src=templates/my.cnf.j2 dest=/etc/mysql/my.cnf mode=0644
-
name: mysqld Daemon Restart
systemd:
state: restarted
name: mariadb.service
enabled: True
```
jinja2 템플릿 내역은 다음과 같다. 참고적으로 핵심적인 내역만은 명시한다.
```
bash
# cat templates/my.cnf.j2
...중략
server-id = {{ server_id }}
...중략
innodb_buffer_pool_size = {{ buffer_pool_size }}
```
`MariaDB 자동설치`에 대한 Playbook 분석
* [ ] MariaDB의 최신버전을 설치하려면, APT의 sources.list 파일에 알맞는 설정을 수행해야 한다.
* [ ] 위의 Playbook은 SLAVE DBMS의 배포로써 server_id,innodb_buffer_pool_size를 변수로 받는다.
* [ ] 큰 틀에서는 기존 설정을 백업하고, 미리 약속된 설정을 배포하는데 유용하다.
## playbook 실행
```
bash
# ansible-playbook -i hosts mariadb_install.yml
```
ANSIBLE/DBMS/README.md
0 → 100644
View file @
8313fcbd
[
![logo
](
https://www.hongsnet.net/images/logo.gif
)
](https://www.hongsnet.net)
# Ansible 활용
> DBMS Maintenance 작업을 수행한다.
# Table of Contents
| NO | ITEM | Content | 비고 |
| ------ | ------ | ------ | ------ |
| 1 | MariaDB Install |
[
GO
](
./MariaDB/
)
| |
| 2 | OS Package Installing (apt) |
[
GO
](
./APT/
)
| |
ANSIBLE/README.md
View file @
8313fcbd
...
...
@@ -11,7 +11,8 @@
| 1 | OS Maintenance ITEMs |
[
GO
](
./OS/
)
| |
| 2 | INFRA Maintenance ITEMs |
[
GO
](
./INFRA/
)
| |
| 3 | WEB Server Maintenance ITEMs |
[
GO
](
./WEB/
)
| |
| 4 | Users Management ITEMs |
[
GO
](
./USER/
)
| |
| 4 | DBMS Maintenance ITEMs |
[
GO
](
./DBMS/
)
| |
| 5 | Users Management ITEMs |
[
GO
](
./USER/
)
| |
| 6 | Virtualization Maintenance ITEMs |
[
GO
](
./VM/
)
| |
| 7 | Secure Vulnerability ITEMs |
[
GO
](
./SECURE/
)
| |
| 8 | MISC ITEMs |
[
GO
](
./MISC/
)
| |
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment