jenkins에서 proxy 설정, update-center 작업을 수작업으로 일반적으로 작업한다. 

절차는 다음과 같다.


1. Use browser for metadata download 설정

Manage Jenkins -> Configure Global Security -> Plugin Manager -> Use browser for metadata download를  check on한다.


2. plugin 관리에서 Proxy 서버를 추가

http://jenkins장비:8080/pluginManager/advanced에서 proxy 설정 넣어야 한다.



이런 작업을 ansible로 자동화 할 수 있다. (1:1로 매핑하기 보다는 잘 동작하게)

- name: Configure Proxy
environment:
no_proxy: "localhost"
jenkins_script:
url: "http://localhost:8080"
script: "{{ lookup('template', 'proxy.groovy') }}"
validate_certs: False
timeout: 120

- name: Change Update-Center protocol
replace:
path: "{{ jenkins_home }}/hudson.model.UpdateCenter.xml"
regexp: 'https://updates.jenkins.io/update-center.json'
replace: 'http://updates.jenkins.io/update-center.json'



templates/proxy.groovy 파일

import jenkins.model.*

def instance = Jenkins.getInstance()

final String name = 'proxy.daumkakao.io'
final int port = 3128
final String noProxyHost = [
'localhost', '127.0.0.1', '127.0.0.0/8',
'...'
].join('\n')

final def proxyConfig = new hudson.ProxyConfiguration(
name, port, null, null, noProxyHost)

instance.proxy = proxyConfig
instance.save()


Posted by '김용환'
,



Jenkins UI에서 플러그인 설치하려 할 때 다음 에러가 난다.

java.net.SocketTimeoutException: connect timed out


jenkins plugin 앤서블에서는 에러가 발생한다.

"details": "HTTP Error 403: Forbidden", 

"msg": "Cannot get CSRF"


이 이유는 바로 proxy 설정 때문에 발생하는 것이다.



Proxy 설정을 잘 주어 젠킨스 플러그인을 설치한다.  jenkins_plugin은 localhost:8080을 호출하기 때문에 no_proxy를 주어야 한다.


 - name: Install jenkins plugins.

  jenkins_plugin:

    owner: "{{default_user}}"

    group: "{{default_group}}"

    jenkins_home: "{{ jenkins_home }}"

    name: "{{ item }}"

    state: latest

  environment:

    no_proxy: "localhost"

    http_proxy: "{{proxy_env.http_proxy}}"

    https_proxy: "{{proxy_env.http_proxy}}"

  with_lines: cat "../../templates/jenkins/plugins/plugins.lst"



Posted by '김용환'
,


맥에서 iterm2를 사용 중인데, 서버에 접근하면 한글 파일이 잘 보이지 않는다.


서버 설정은 잘 되어 있다.

$ env|grep LC

LC_ALL=ko_KR.utf8

$ env|grep LANG

LANG=ko_KR.utf8



한글 디렉토리와 파일은 ???로 나타난다.

jenkins를 실행하면 제대로 파일을 읽지 못한다.


SEVERE: Could not restore backup.

java.io.FileNotFoundException: /google/program/jenkins_backup/jobs/(?????????) ansible-common (No such file or directory)

at java.io.FileInputStream.open0(Native Method)

at java.io.FileInputStream.open(FileInputStream.java:195)


이유는 무척 단순했다.

최근 맥북을 받았는데. LC와 LANG을 설정이 안되어 있는데..


$ env | grep LC

$ env | grep LANG


iterm 기본 설정은 로컬 변수를 서버까지 가지고 가는 형태였다.(대박.)


따라서 맥북에 iterm2를 사용할 때는 반드시 Profiles/Terminal/Environment을 살펴보고.

Set locale variable automatically 설정은 check off해야 한다.





서버 설정이 아니라 내 기본 설정 이슈였다.

'scribbling' 카테고리의 다른 글

무표 폰트 다운로드받는 곳  (0) 2019.08.06
물류 쪽 관련 내용 스크랩  (0) 2019.07.26
펌) 마이그레이션 전략  (0) 2019.04.24
구글의 원격 협업 관련 내용  (0) 2019.04.05
MCN  (0) 2019.04.01
Posted by '김용환'
,

scala cats 공부 자료.

scala 2019. 6. 18. 20:53
Posted by '김용환'
,


git 프로젝트를 다운받을 때 github key를 사용해 다운로드 한다. 


앤서블을 사용하는 첫 번째 방법 - ~/.ssh/config 파일을 수정한다

Host github.com

  IdentityFile ~/.ssh/github_rsa


- name: Download config
git:
repo: git@github.com:uj/config.git
dest: "{{program_path}}/config"
force: yes
clone: yes



앤서블을 사용하는 두 번째 방법 - 직접 key 파일을 가르키게 한다.


- name: Download thin-backup source
git:
repo: git@github.com:uj/config.git
dest: "{{program_path}}/config"
force: yes
clone: yes
accept_hostkey: yes
key_file: /home/www/.ssh/github_rsa


Posted by '김용환'
,

ansible jenkins 레시피를 추가할 때 가장 애먹은 부분이 proxy 부분이었다. 


tasks/main.xml 파일 

- name: Install jenkins plugins.
jenkins_plugin:
owner: "{{default_user}}"
group: "{{default_group}}"
jenkins_home: "{{ jenkins_home }}"
name: "{{ item.key }}"
version: "{{ item.value.version }}"
state: latest
timeout: 10
environment:
no_proxy: "localhost"
http_proxy: "{{proxy_env.http_proxy}}"
https_proxy: "{{proxy_env.http_proxy}}"
with_dict: "{{ plugins }}"

가장 주의할 점은 바로 no_proxy:localhost이다.



vars/main.xml 파일

---
plugins:
git:
version: 3.9.1
ace-editor:
version: 1.1
scm-sync-configuration:
version: 0.0.10
workflow-job:
version: 2.24

새로 설치할 때는 형상 관리 차원에서 이 방식 또는 jenkins docker 방식을 사용하는 것이 좋다.


그러나..

기존 (legacy) 젠킨스에 playbook이 없어서 동일하게  플러그인 이름과 버전을 맞춰놔도 플러그인 간의 dependecy가 깨지는 경우가 많다. 

따라서 플러그인 설치는 따로 playbook을 설치하기보다는 기존 plugins 파일 들을 압축 저장해서 장애에 대비하는 것이 좋다. 시간을 엄청 빨리 아낄 수 있다. 따로 ftp 서버에 올려두고 재설치 레시피(플레이북)에서 사용하도록 한다.

Posted by '김용환'
,