- get_url 모듈을 사용하려면 libselinux-python이 기본으로 설치되어 있어야함
- 기본적으로 wget보다는 get_url 모듈을 사용 권장하지만 libselinux-python이 설치 되어 있지 않아 사용 불가능 할 경우에는 wget을 사용해야함
- 서버에 libselinux-python 설치 진행하면 get_url 모듈 사용 가능
- wget은 ansible에서는 기본적으로는 권장 X → wget은 모듈이 아니라 shell 모듈에 wget 명령어를 사용하기에 get_url 모듈 사용 권장
get_url 모듈을 사용하였을 때 문제가 발생하는 문구 → Aborting, target uses selinux but python bindings (libselinux-python) aren't installed!"
get_url 모듈을 사용하는 yml 파일
$ vi login_change.yml
---
- hosts: test
gather_facts: no
become: no
tasks:
- name: download login
get_url:
url : http://setting.hippo.com/install/os/login_policy_change.sh
dest : /root/login_policy_change.sh
- name: execute login policy change
shell: "source /root/login_policy_change.sh"
register: change_result
- name: print change result
debug:
msg:
- "{{ change_result.stdout.split('\n') }}"
shell 모듈에 wget 명령어를 사용하는 yml 파일
$ vi login_change_update.yml
---
- hosts: test
gather_facts: no
become: no
tasks:
- name: download login
shell: "wget -P /root/ http://setting.hippo.com/install/os/login_policy_change.sh"
- name: execute login policy change
shell: "source /root/login_policy_change.sh"
register: change_result
- name: print change result
debug:
msg:
- "{{ change_result.stdout.split('\n') }}"
'Ansible(앤서블)' 카테고리의 다른 글
ansible 변수(vars) (0) | 2022.07.24 |
---|---|
ansible의 handler → Running Operations On Change (0) | 2022.07.24 |
ansible의 Include_tasks → ansible의 외부 yaml 파일 사용 (0) | 2022.07.24 |
ansible의 if → ansible 조건문 (0) | 2022.07.24 |
ansible의 When → ansible 조건문 사용 (0) | 2022.07.24 |