티스토리 뷰
▶ shell 은 메타문자를 처리할 수 있다
[vagrant@control ~]$ ansible node1 -m shell -a 'ps -ef | grep bash'
node1 | CHANGED | rc=0 >>
vagrant 1340 1339 0 09:48 pts/0 00:00:00 /bin/sh -c ps -ef | grep bash
vagrant 1342 1340 0 09:48 pts/0 00:00:00 grep bash
[vagrant@control ~]$ ansible node1 -m command -a 'ps -ef | grep bash'
node1 | FAILED | rc=1 >>
error: garbage option
Usage:
ps [options]
Try 'ps --help <simple|list|output|threads|misc|all>'
or 'ps --help <s|l|o|t|m|a>'
for additional help text.
For more details see ps(1).non-zero return code
▷ changed 는 발생했지만, file 이 만들어지지는 않았다
▷ command 는 멱등성이 없으며, 에러만 나지 않으면 모두 changed 가 발생한다
[vagrant@control ~]$ ansible localhost -m command -a 'echo hello > /tmp/myfile.txt'
localhost | CHANGED | rc=0 >>
hello > /tmp/myfile.txt
[vagrant@control ~]$ cat /tmp/myfile.txt
cat: /tmp/myfile.txt: No such file or directory
[vagrant@control ~]$ ansible localhost -m shell -a 'echo hello > /tmp/myfile.txt'
localhost | CHANGED | rc=0 >>
[vagrant@control ~]$ cat /tmp/myfile.txt
hello
[vagrant@control ~]$
'Ansible' 카테고리의 다른 글
Role 실습 (0) | 2024.02.22 |
---|---|
Role (0) | 2024.02.20 |
Template ( 템플릿 ) (0) | 2024.02.20 |
Handlers 추가내용 (0) | 2024.02.20 |
fact 변수 활용 (0) | 2024.02.20 |