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
8c750e81
Commit
8c750e81
authored
Mar 08, 2021
by
JooHan Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ansible, 2021-03-08, update12
parent
8313fcbd
Pipeline
#5121
passed with stages
in 2 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
0 deletions
+117
-0
README.md
ANSIBLE/WEB/Nginx/README.md
+105
-0
README.md
ANSIBLE/WEB/README.md
+12
-0
No files found.
ANSIBLE/WEB/Nginx/README.md
0 → 100644
View file @
8c750e81
[
![logo
](
https://www.hongsnet.net/images/logo.gif
)
](https://www.hongsnet.net)
# Ansible의 copy,file 모듈 이용한 Nginx 설치
> Nginx 설치를 자동화 할 수 있다.
## 주요 기능
-
특정 버전의 Nginx WEB Server를 설치한다.
-
미리 검증된 Configs를 배포한다.
## 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 : Nginx Deploy Playbook
hosts: ALL_HOSTS
vars:
time: "{{lookup('pipe','date
\"
+%Y-%m-%d
\"
')}}"
nginx_version: "1.10.3-1+deb9u3"
tasks:
-
name: Nginx {{ nginx_version }} Install
apt:
pkg:
-
nginx=1.10.3-1+deb9u3
-
name: /etc/nginx_src directory check
stat:
path: /etc/nginx_src
register: nginx_check
-
name: Nginx Basic Setting file Backup
command: cp -rfp /etc/nginx /etc/nginx_src
when: nginx_check.stat.exists == False
-
name: Nginx config files copy
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
owner: 'root'
group: 'root'
with_items:
-
{ src: configs/any/nginx.conf, dest: /etc/nginx/nginx.conf }
-
{ src: configs/any/default.conf, dest: /etc/nginx/sites-available/default }
-
name: Nginx config files permission set
file:
path: "{{ item.path }}"
mode: "{{ item.mode }}"
with_items:
-
{ path: /etc/nginx/nginx.conf, mode: 644 }
-
{ path: /etc/nginx/sites-available/default, mode: 644 }
register: nginx_config
-
name: Nginx Daemon Restart
systemd:
state: restarted
name: nginx.service
enabled: True
when: nginx_config.changed
```
`Nginx 자동설치`에 대한 Playbook 분석
* [ ] 위의 Playbook은 Nginx의 기본설정을 배포를 수행한다.
* [ ] 큰 틀에서는 기존 설정을 백업하고, 미리 약속된 설정을 배포하는데 유용하다.
## playbook 실행
```
bash
# ansible-playbook -i hosts nginx_install.yml
```
ANSIBLE/WEB/README.md
0 → 100644
View file @
8c750e81
[
![logo
](
https://www.hongsnet.net/images/logo.gif
)
](https://www.hongsnet.net)
# Ansible 활용
> WEB Server의 Maintenance 작업을 수행한다.
# Table of Contents
| NO | ITEM | Content | 비고 |
| ------ | ------ | ------ | ------ |
| 1 | Nginx Install |
[
GO
](
./Nginx/
)
| |
| 2 | OS Package Installing (apt) |
[
GO
](
./APT/
)
| |
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