본문 바로가기

전체 글210

[ansible] 앤서블 playbook iptables 다수의 값 반복 문 playbook 동일한 구문에 변수값만 변경하면서 넣으려면 with_items를 쓰면된다. iptables 정책을 넣기위한 yml 예제는 다음과 같다 --- - name: iptables add hosts: 10.128.0.37 gather_facts: false become: yes vars: ansible_become_password: "Dlatldkagh1!" tasks: - name : 'add iptables dport {{ item.port }}' iptables: chain: INPUT source: '{{ item.addhost }}' protocol: '{{ item.proto }}' destination_port: '{{ item.port }}' ctstate: NEW jump: '{{.. 2022. 6. 3.
[jenkins] cenots7 젠킨스 https ssl 인증서 설치 젠킨스 설정에 관해 구글에 검색해보면 죄다 /etc/sysconfig/jenkins 에서 수정해서 재적용하면 된다고 하지만 2022년 cenots7 에서 yum으로 젠킨스를 설치하여 젠키스 버전 2.332.2 인 나의 환경에서는 해당 파일에서의 설정이 서비스를 재구동하여도 전혀 먹히지 않았다 결과적으로 해당 설정파일에서 설정하는게 아니라 /usr/lib/systemd/system/jenkins.service 에서 설정을 서비스 재시작을 해야 설정이 먹히는 것을 알고 있어야 한다. 아래는 개인키/인증 요청서/ 인증서/jks 파일 변환 방법이다. 젠킨스 ssl인증서 설치의 경우 jks파일로 설치를 해야한다. ## 개인키 생성 ## 2048bit RSA 암호화 인증서 openssl genrsa -des3 -o.. 2022. 6. 2.
[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.
docker IP 대역 변경하기 docker설치 후 컨테이너를 올리면 기본 아이피가 172.xx.xx.xx 대역으로 할당되어진다. 회사에서 172대역을 사용하면 아래와 같이 설정한다 # 폴더생성 mkdir -p /etc/docker # 파일생성 vi /etc/docker/daemon.json { "bip": "10.10.0.1/24", "default-address-pools": [ {"base":"10.10.0.1/16","size":24} ] } # 서비스 재시작 systemctl restart docker #docker network 설정 적용내역 확인 docker netowrk inspect bridg 그렇다면 이미 만든 컨테이너가 있을 경우는? 위에 설정을 수행하고 적용된것을 확인 후 기존 컨테이너를 삭제하고 다시 할당하면 된.. 2022. 5. 30.
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.
ansible playbook debug passwd 프린트 하기 원하는 호스트의 /etc/passwd에 있는 계정리스트를 출력하고자한다. {{ 변수명.stdout_lines }}의 stdout_lines를 쓰면 결과가 깔끔하게 출력됨 --- - name: print passwd hosts: "{{ varhost }}" tasks: - name: print passwdaa shell: cat /etc/passwd | awk -F ':' '{print $1}' register: print_result - name: debug print debug: msg: "{{ print_result.stdout_lines }}" 수행명령어 ansible-playbook printpasswd.yml -e "varhost=localhost" -k 2022. 5. 24.
svn 명령어 프로젝트 불러오기 svn checkout svn으로 파일 업로드하기 add와 commit을 해줘야 다음에 당겨받을때 추가한 파일까지 당겨온다. svn add 파일명 svn commit 파일명 -m "메시지" svn에 수정된 내역을 받아오기 svn update 2022. 5. 24.
반응형