앤서블을 사용해 압축 파일을 복사하려고 하는데 에러가 발생했다.

copy: src={{downlod_result_jenkins.dest}}
dest={{service_path}}/jenkins
remote_src=no
group={{default_user}}
owner={{default_group}}

FAILED! => {"changed": false, "msg": "Could not find or access '/file.war' on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"}




https://github.com/ansible/ansible/issues/31926을 보니 일부러 앤서블에서 막은 듯 해서.

아래와 같이 압축 파일 복사는 다음과 같이 command 모듈을 사용해 진행했다.


- name : jenkins 복사 - {{service_path}}/jenkins
command: cp -r {{downlod_result_jenkins.dest}}\ {{service_path}}/jenkins


Posted by '김용환'
,



변수 출력하기

- command: "ls {{downlod_result_jenkins.dest}}"
register: dir_out

- debug: var={{item}}
with_items: dir_out.stdout_lines


Posted by '김용환'
,



특정 파일을 제외하고 하위 디렉토리의 모든 디렉토리와 파일을 지울 때..

물어보길 원할 때 다음과 같은 커맨드를 사용하면 유용하다.


$ find . -maxdepth 1 -type d -not -name "google" -not -name "gift-wine*" -exec rm -ri {} \;


결과는 다음 화면이 나온다.

rm: "." and ".." may not be removed

하나씩 물어봄


Posted by '김용환'
,