我正在尝试在Linux Ubuntu Xenial 16.04 LTS AMD 64服务器上使用Ansible完全配置Jenkins服务器。目前,我可以使用Ansible执行以下操作:
但是,我不知道现在如何使用Ansible自动配置我的所有Jenkins管道。
我已经在Google上进行了一些研究,但无法提出使用特定的Ansible模块或Jenkins CLI进行此操作的方法。
有人知道我能做到这一点吗?
我在下面提供了当前Ansible剧本以供参考。
- name: Install add-apt-repostory
become: yes
apt: name=software-properties-common
state=latest
- name: Add Oracle Java Repository
become: yes
apt_repository: repo='ppa:webupd8team/java'
- name: Accept Java 8 License
become: yes
debconf: name='oracle-java8-installer'
question='shared/accepted-oracle-license-v1-1'
value='true'
vtype='select'
- name: Install Oracle Java 8
become: yes
apt: name={{item}} state=latest
with_items:
- oracle-java8-installer
- ca-certificates
- oracle-java8-set-default
- name: Download jenkins key & add key to apt to verify jenkins package
# need to use the shell module (command) to execute commands through the remote
# nodes shell which enables the use of | and other operators
shell: wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
- name: Copy jenkins list
command: sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
- name: update apt package to detect jenkins
command: sudo apt-get update
- name: Jenkins - Installs, start and register as a service.
command: sudo apt-get install jenkins -y
- name: Disable Jenkins setup wizard
lineinfile:
dest=/etc/default/jenkins
regexp=^JAVA_ARGS=
line=JAVA_ARGS="-Djava.awt.headless=true -Djenkins.install.runSetupWizard=false"
become: true
- name: Create initialization scripts directory
file: path=/var/lib/jenkins/init.groovy.d
state=directory
owner=jenkins
group=jenkins
mode=0775
- name: Add initialization script to setup basic security
template: src=security.groovy.j2
dest=/var/lib/jenkins/init.groovy.d/security.groovy
- name: restart jenkins
service: name=jenkins state=restarted