[JENKINS] - ANSIBLE 연동


1. 플러그인 설치 ansible plugin


2. Global Tool Config

Alt text


3. Credential 추가 - system - global credentials

Alt text


4. 빌드 추가 invoke ansible ad-hoc command

Alt text


5. credential 등록을 했음에도 에러가 난다…

Alt text


6. jenkins 권한으로도 ssh key를 등록해야한다.

root에서는 ansible all -a “ls” 명령이 잘된다.

jenkins로 변경 후 테스트

1
2
3
4
5
6
su -s /bin/bash jenkins
xxx.xxx.xxx.xxx | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Warning: Permanently added 'xxx.xxx.xxx.xxx' (ECDSA) to the list of known hosts.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic,password).",
"unreachable": true
}

ssh 위치는 /var/lib/jenkins/.ssh

root .ssh/ 파일들을 복사해준다.

1
2
3
4
5
6
7
8
9
10
11
12
13
ansible all -a "ls" 

xxx.xxx.xxx.xxx | CHANGED | rc=0 >>
1
cx
node-v10.13.0
node-v10.13.0-linux-x64
node-v10.13.0-linux-x64.tar
node-v10.13.0.tar.gz
remi-release-7.5-2.el7.remi.noarch.rpm
zabbix-agent-3.4.11-1.el7.x86_64.rpm
zabbix-tcp-master
Finished: SUCCESS

7. 최종 빌드 테스트

Alt text