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
localhost
Prac 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.13
Create 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.yml
Execute Ansible-Playbook
ansible-playbook bloter.yml
Check result of Ansible-Playbook
cat /etc/ansible/hosts
Prac 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=started
Create 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.yml
Execute Ansible-Playbook
ansible-playbook nginx.yml -k
Disable default firewall in nginx
ansible server -m shell -a "systemctl stop firewalld"
Download nginx defualt page
curl -o index.html https://www.nginx.com
Change 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.yml
Share article