Introduction
Thank you for clicking through to my arcticle. I've been a DevOps engineer for 2 years in dev-team of 7 engineers.
My name is MINSEOK, LEE, but I use Unchaptered as an alias on the interenet. So, you can call me anythings "MINSEOK, LEE" or "Unchaptered" to ask something.
Topic
Prac 1 : set-up hosts in
localhostPrac 2 : set-up NGINX Sinario
Install NGINX.
Send NGINX configuration file.
Restart NGINX.
Prerequisites
What is the idempotent?
The result is always the same no matter how many times you apply the operation
Prac 1 : Set-up hosts in localhost
Reference File
- name : Ansible_Vim
hosts: localhost
tasks:
- name: Add ansible_hosts
blockinfile:
path: /etc/ansible/hosts
block: |
[bloter]
192.168.1.13Create Ansible-Playbook File
echo "- name : Ansible_Vim
hosts: localhost
tasks:
- name: Add ansible_hosts
blockinfile:
path: /etc/ansible/hosts
block: |
[bloter]
192.168.1.13" > bloter.ymlExecute Ansible-Playbook
ansible-playbook bloter.ymlCheck result of Ansible-Playbook
cat /etc/ansible/hostsPrac 2 : Set-up NGINX Scenario
Reference File
- hosts: server
remote_user: root
tasks:
- name: Install epel-release
yum: name=epel-release state=latest
- name: Install nginx web server
yum: name=nginx state=present
- name: Start nginx web server
service: name=nginx state=startedCreate nginx.yml file
echo "- hosts: server
remote_user: root
tasks:
- name: Install epel-release
yum: name=epel-release state=latest
- name: Install nginx web server
yum: name=nginx state=present
- name: Start nginx web server
service: name=nginx state=started" > nginx.ymlExecute Ansible-Playbook
ansible-playbook nginx.yml -kDisable default firewall in nginx
ansible server -m shell -a "systemctl stop firewalld"Download nginx defualt page
curl -o index.html https://www.nginx.comChange nginx.yml file
echo "- hosts: server
remote_user: root
tasks:
- name: Install epel-release
yum: name=epel-release state=latest
- name: Install nginx web server
yum: name=nginx state=present
- name: Upload default index.html for webserver
copy: src=index.html dest=/usr/share/nginx/html mode=0644
- name: Start nginx web server
service: name=nginx state=started" > nginx.ymlShare article