Ansible/Jenkinsの導入 のバックアップ(No.1) |
|
Jenkinsは、どのような方式でも導入は簡単ですが、本件では公式RPMで導入する。RPMで導入すると、Jenkinsの更新をyumコマンドで実施完了してしまえるメリットがある。
proxy=http://proxy.jomura.net:8080/ #as your own~/.bashrc
export HTTP_PROXY=http://proxy.jomura.net:8080/ #as your own export HTTPS_PROXY=${HTTP_PROXY}
yum clean all && yum -y update && reboot
cat << "_EOF_" > pb_jenkins_server.yml # install jenkins - hosts: jenkins_servers become: true become_method: su environment: "{{ proxy_env }}" tasks: - name: facts check fail: msg: "Not compatible with [{{ ansible_os_family }}] {{ ansible_distribution }} {{ ansible_distribution_major_version }}." when: ansible_os_family != 'RedHat' or ansible_distribution_major_version|int < 7 - name: install Java11 yum: name: java-11-openjdk state: latest - name: port forward shell: firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080 --permanent register: result changed_when: '"Warning: ALREADY_ENABLED: " not in result.stderr' notify: reload firewalld - name: jenkins yum repository yum_repository: name: jenkins description: jenkins YUM repo baseurl: "http://pkg.jenkins.io/redhat-stable/" - name: jenkins.io key installed rpm_key: key: "http://pkg.jenkins.io/redhat-stable/jenkins.io.key" - name: "Jenkins installed" yum: name: jenkins state: latest - name: "Jenkins service started" service: name: jenkins state: started enabled: yes handlers: - name: reload firewalld service: name=firewalld state=restarted _EOF_
ansible-playbook -i inventory.yml pb_jenkins_server.yml