변군이글루

[오픈소스] Ansible 일반 계정으로 배포하기 본문

프___기타

[오픈소스] Ansible 일반 계정으로 배포하기

변군 변군이글루 2017.04.16 20:47

Ansible 일반 계정으로 배포하기

[Control Machine]
1. ansiadmin 계정 ssh keygen 생성
ssh-keygen -t rsa -b 4096 -C "ansiadmin@ass01"

2. ansiadmin 계정 키 교환(192.168.0.252 서버로 배포)
ssh-copy-id ansiadmin@192.168.0.252

3. yaml 파일 수정
$ cat roles/common/tasks/main.yml
-----      
---
# This playbook contains common plays that will be run on all nodes.

- name: Install ntp
  yum: name=ntp state=present
  tags: ntp
  become: yes
  become_method: sudo

- name: Configure ntp file
  become: yes
  become_method: sudo
  template: src=ntp.conf.j2 dest=/etc/ntp.conf
  tags: ntp
  notify: restart ntp

- name: Start the ntp service
  become: yes
  become_method: sudo
  service: name=ntpd state=started enabled=yes
  tags: ntp

- name: test to see if selinux is running
  become: yes
  become_method: sudo
  command: getenforce
  register: sestatus
  changed_when: false
-----

4. ansible-playbook 실행(패키지 배포)
$ ansible-playbook site.yml
-----
PLAY [apply common configuration to all nodes] *********************************

TASK [setup] *******************************************************************
ok: [192.168.0.252]

TASK [common : Install ntp] ****************************************************
ok: [192.168.0.252]

TASK [common : Configure ntp file] *********************************************
ok: [192.168.0.252]

TASK [common : Start the ntp service] ******************************************
changed: [192.168.0.252]

TASK [common : test to see if selinux is running] ******************************
ok: [192.168.0.252]

PLAY RECAP *********************************************************************
192.168.0.252              : ok=5    changed=1    unreachable=0    failed=0
-----

[Managed Node]
5-1. Ansible 클라이언트 서버에서 일반 계정에 권한 부여
$ sudo cat /etc/sudoers | grep ansiadmin
ansiadmin        ALL=(ALL)       NOPASSWD: ALL

5-2. Node 서버 패키지 설치된 패키지 확인
$ sudo rpm -qa | grep ntp
ntpdate-4.2.6p5-10.el6.centos.2.x86_64
ntp-4.2.6p5-10.el6.centos.2.x86_64

5-3. Node 서버 ntp.conf 파일 확인
$ sudo cat /etc/ntp.conf
-----
driftfile /var/lib/ntp/drift

restrict 127.0.0.1
restrict -6 ::1

server 192.168.1.2

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys
-----



0 Comments
댓글쓰기 폼