UFO ET IT

Ansible : Ansible Playbook에서 Active Directory를 변경하는 방법은 무엇입니까?

ufoet 2021. 1. 7. 08:20
반응형

Ansible : Ansible Playbook에서 Active Directory를 변경하는 방법은 무엇입니까?


- name: Go to the folder
  command: chdir=/opt/tools/temp

플레이 북을 실행하면 다음을 얻습니다.

TASK: [Go to the folder] ***************************** 
failed: [host] => {"failed": true, "rc": 256}
msg: no command given

어떤 도움이라도 대단히 감사합니다.


Ansible에는 현재 디렉토리에 대한 개념이 없습니다. 플레이 북에서했던 것처럼 특정 작업에 대한 현재 디렉토리를 지정할 수 있습니다. 유일하게 빠진 부분은 실행할 실제 명령이었습니다. 이 시도:

- name: Go to the folder and execute command
  command: chdir=/opt/tools/temp ls

이 질문은 chdir내가 Ansible 1.9로 되돌려 야 할 때 왜 'shell'이 내 항목을 존중하지 않는지 알아 내려고 할 때의 결과였습니다 . 그래서 내 솔루션을 게시 할 것입니다.

나는 가지고 있었다

- name: task name
  shell:
    cmd: touch foobar
    creates: foobar
    chdir: /usr/lib/foobar

Ansible> 2에서 작동했지만 1.9에서는 변경해야했습니다.

- name: task name
  shell: touch foobar
  args:
    creates: foobar
    chdir: /usr/lib/foobar

공유하고 싶었습니다.


(번 들러와 같은) 로그인 콘솔이 필요한 경우 다음과 같은 명령을 수행해야합니다.

command: bash -lc "cd /path/to/folder && bundle install"

참조 URL : https://stackoverflow.com/questions/19369931/ansible-how-to-change-active-directory-in-ansible-playbook

반응형