본문 바로가기
인프라/앤서블(Ansible)

ansible awx windows playbook example

by IT맥구리나스 2022. 5. 2.

ansible awx에서 windows 노드들에 수행할 playbook 예제

직접 테스트한 것만 올렸다.

 

아래 사이트를 참조하였다.

https://www.devopsschool.com/tutorial/ansible/ansible-windows-playbooks.html

 

계정 추가

---
- name: Add a user
  hosts: all
  gather_facts: false
  tasks:
    - name: Add User
      win_user:
        name: ansible
        password: "Wlsldks123!"
        state: present

 

hostname 변경

---
- hosts: all
  tasks:
   - name: Change the hostname to sample-hostname
     win_hostname:
      name: sample-hostname
     register: res
   - name: Reboot
     win_reboot:
     when: res.reboot_required

 

ping테스트

---
- hosts: all
  tasks:
   - name: Ping Windows Hosts
     win_ping:

 

서비스 name은 아래와 같이 확인한다.

서비스 중단(Google Compute Engine)

---
- hosts: all
  tasks:
   - name: Stop service google commpute engine
     win_service:
       name: GCEAgent
       state: stopped

 

서비스 시작(Google Compute Engine)

---
- hosts: all
  tasks:
   - name: Start service google commpute engine
     win_service:
       name: GCEAgent
       state: started
반응형

댓글