본문 바로가기

인프라/앤서블(Ansible)48

[ansible] 앤서블 출력 관련 playbook yml 출력은 어떻게 하나? 먼저 변수를 선언하고 결과 값을 변수에 담아야한다. #yml파일 --- - hosts: localhost tasks: - name: check hostname shell: hostname -f register: "check_hostname" - name: debug result debug: msg: "{{ check_hostname }}" # 실행 # ansible-playbook expect.yml PLAY [localhost] ***********************************************************************************************************************************************.. 2022. 6. 1.
[ansible] 앤서블 yml 특수문자 ecaspe 처리 yml 파일을 작성할 때 특수문자를 escape(\처리)하는게 중요하다. 이번에 expect 모듈을 쓰면서 느끼는거지만 특수문자같이 생긴건 이 잡듯이 잡아 특수문자 앞에 \를 넣어줘야한다. 여기서 말하는 특수문자는 다음과 같다. {, }, [, ], &, *, #, ?, |, -, , =, !, %, @ 예를 들어보겠다. 아래는 입력 파라메터 문장이 맞으면 자동으로 값을 입력하는 expect모듈을 이용한 yml 파일이다 입력 파라메터 문장에 특수문자가 전혀 없기 때문에 문제없어보인다. - hosts: localhost tasks: - name: Test Script expect: command: /home/jenkins/test.sh responses: enter on: 'one' enter two: '.. 2022. 6. 1.
[ansible] The error was: ImportError: No module named pexpect 코드 #!/bin/bash echo "Press 'y' to confirm ('s' to skip, 'a' to abort):" read response echo $response 플레이북 --- - hosts: localhost tasks: - name: "Execute app" expect: command: /home/jenkins/test.sh responses: Press 'y' to confirm \('s' to skip\, 'a' to abort\):: "y" echo: yes 에러내용 An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ImportError: No modu.. 2022. 5. 31.
Ansible awx hostname으로 찍히게 하려면 awx에서hostname을 그대로 적으면 찾지를 못한다. 그렇기때문에 VARIABLES에 아래와 같이 입력해주고 실행하면 된다. 2022. 5. 26.
ansible "basic: the specified credentials were rejected by the server" 문제점 - ansible을 이용하여 windows서버에 명령을 수행하면 아래와 같은 에러가 발생함. x.x.x.x | UNREACHABLE! => { "changed": false, "msg": "basic: the specified credentials were rejected by the server", "unreachable": true } 해결방법 해당 윈도우 서버에 파워쉘로 아래 명령어 수행 Set-Item -Force WSMan:\localhost\Client\Allowunencrypted $True Set-Item -Force WSMan:\localhost\Service\Allowunencrypted $True Set-Item -Force WSMan:\localhost\Service\auth.. 2022. 5. 25.
반응형