The agent is downloaded and configured to start at boot. The secrets needed to prove the workers' identity to the Jenkins server are stored inside Ansible vaults. Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx> --- ansible/ansible.cfg | 1 + ansible/group_vars/all/main.yml | 2 + ansible/host_vars/libvirt-centos-6/main.yml | 3 ++ ansible/host_vars/libvirt-centos-6/vault.yml | 10 ++++ ansible/host_vars/libvirt-centos-7/main.yml | 3 ++ ansible/host_vars/libvirt-centos-7/vault.yml | 10 ++++ ansible/host_vars/libvirt-debian-8/main.yml | 3 ++ ansible/host_vars/libvirt-debian-8/vault.yml | 10 ++++ ansible/host_vars/libvirt-debian-9/main.yml | 3 ++ ansible/host_vars/libvirt-debian-9/vault.yml | 10 ++++ ansible/host_vars/libvirt-fedora-25/main.yml | 3 ++ ansible/host_vars/libvirt-fedora-25/vault.yml | 10 ++++ ansible/host_vars/libvirt-fedora-26/main.yml | 3 ++ ansible/host_vars/libvirt-fedora-26/vault.yml | 10 ++++ ansible/host_vars/libvirt-fedora-rawhide/main.yml | 3 ++ ansible/host_vars/libvirt-fedora-rawhide/vault.yml | 10 ++++ ansible/host_vars/libvirt-freebsd-10/main.yml | 3 ++ ansible/host_vars/libvirt-freebsd-10/vault.yml | 10 ++++ ansible/host_vars/libvirt-freebsd-11/main.yml | 3 ++ ansible/host_vars/libvirt-freebsd-11/vault.yml | 10 ++++ ansible/host_vars/libvirt-ubuntu-12/main.yml | 3 ++ ansible/host_vars/libvirt-ubuntu-12/vault.yml | 8 +++ ansible/host_vars/libvirt-ubuntu-14/main.yml | 3 ++ ansible/host_vars/libvirt-ubuntu-14/vault.yml | 8 +++ ansible/host_vars/libvirt-ubuntu-16/main.yml | 3 ++ ansible/host_vars/libvirt-ubuntu-16/vault.yml | 8 +++ ansible/site.yml | 7 +++ ansible/tasks/jenkins.yml | 59 ++++++++++++++++++++++ ansible/templates/jenkins.service.j2 | 14 +++++ ansible/vars/mappings.yml | 8 +++ ansible/vars/projects/jenkins.yml | 3 ++ 31 files changed, 244 insertions(+) create mode 100644 ansible/host_vars/libvirt-centos-6/vault.yml create mode 100644 ansible/host_vars/libvirt-centos-7/vault.yml create mode 100644 ansible/host_vars/libvirt-debian-8/vault.yml create mode 100644 ansible/host_vars/libvirt-debian-9/vault.yml create mode 100644 ansible/host_vars/libvirt-fedora-25/vault.yml create mode 100644 ansible/host_vars/libvirt-fedora-26/vault.yml create mode 100644 ansible/host_vars/libvirt-fedora-rawhide/vault.yml create mode 100644 ansible/host_vars/libvirt-freebsd-10/vault.yml create mode 100644 ansible/host_vars/libvirt-freebsd-11/vault.yml create mode 100644 ansible/host_vars/libvirt-ubuntu-12/vault.yml create mode 100644 ansible/host_vars/libvirt-ubuntu-14/vault.yml create mode 100644 ansible/host_vars/libvirt-ubuntu-16/vault.yml create mode 100644 ansible/tasks/jenkins.yml create mode 100644 ansible/templates/jenkins.service.j2 create mode 100644 ansible/vars/projects/jenkins.yml diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg index ca02677..2055540 100644 --- a/ansible/ansible.cfg +++ b/ansible/ansible.cfg @@ -6,3 +6,4 @@ log_path = ./log nocows = 1 pipelining = True squash_actions = package +vault_password_file = ~/.ansible/libvirt-jenkins-ci.vault-password diff --git a/ansible/group_vars/all/main.yml b/ansible/group_vars/all/main.yml index e8d3cb6..81b7d43 100644 --- a/ansible/group_vars/all/main.yml +++ b/ansible/group_vars/all/main.yml @@ -1,6 +1,8 @@ --- ansible_user: root +jenkins_url: https://ci.centos.org/computer/{{ inventory_hostname }}/slave-agent.jnlp + # Paths to various command. Can be overridden on a per-host basis bash: /bin/bash java: /usr/bin/java diff --git a/ansible/host_vars/libvirt-centos-6/main.yml b/ansible/host_vars/libvirt-centos-6/main.yml index e959ecc..f6b64f3 100644 --- a/ansible/host_vars/libvirt-centos-6/main.yml +++ b/ansible/host_vars/libvirt-centos-6/main.yml @@ -1,7 +1,10 @@ --- projects: - base + - jenkins - libvirt - libvirt-cim - libvirt-perl - libvirt-python + +jenkins_secret: '{{ vault_jenkins_secret }}' diff --git a/ansible/host_vars/libvirt-centos-6/vault.yml b/ansible/host_vars/libvirt-centos-6/vault.yml new file mode 100644 index 0000000..2522a28 --- /dev/null +++ b/ansible/host_vars/libvirt-centos-6/vault.yml @@ -0,0 +1,10 @@ +$ANSIBLE_VAULT;1.1;AES256 +33376164643732313335383930346630343432643939303864313631353063636663663634616638 +3062306563323630653033656231373634363932336331620a383065336664343663346562353862 +64616131656633653338316232303562363632643530313961316130303335626235653430326530 +3566363365323830660a363063623035333231396337393537626161363634313637323563643161 +36613030333563363630363730656238646138306236643937623266646639616130343734313566 +61356165383464323434333836333030336464326436373731313439626161653931626431343665 +30306236333133333334656430636363366132323132323039356264636465333630653335396662 +38356334386337386135343463323233666432326361656438333961303237353562656339623264 +3765 diff --git a/ansible/host_vars/libvirt-centos-7/main.yml b/ansible/host_vars/libvirt-centos-7/main.yml index fe33bcd..1eea74d 100644 --- a/ansible/host_vars/libvirt-centos-7/main.yml +++ b/ansible/host_vars/libvirt-centos-7/main.yml @@ -1,6 +1,7 @@ --- projects: - base + - jenkins - libosinfo - libvirt - libvirt-cim @@ -14,3 +15,5 @@ projects: - osinfo-db-tools - virt-manager - virt-viewer + +jenkins_secret: '{{ vault_jenkins_secret }}' diff --git a/ansible/host_vars/libvirt-centos-7/vault.yml b/ansible/host_vars/libvirt-centos-7/vault.yml new file mode 100644 index 0000000..86367e5 --- /dev/null +++ b/ansible/host_vars/libvirt-centos-7/vault.yml @@ -0,0 +1,10 @@ +$ANSIBLE_VAULT;1.1;AES256 +66663634303664343734626532356561373665336632383463666536356637626637393231353062 +3939383563383338663532336237623766346238316632340a663335353430333635343534333032 +63613530356333316131663565303537386364353039343933653364623661386338383530633665 +3738313139376133370a373731353034633439303965303735613666653133363665356633353564 +64343164633764636130653762303535636634613637303437636266386337376565343765616338 +35656162313662346338353833373564633138306332616562646566343237613638376166303264 +61373864343337326265653364363730336161343733663365656138333738323632373664343334 +62313666316266663162313238653338613761623033636632653736363036353937626566353932 +6234 diff --git a/ansible/host_vars/libvirt-debian-8/main.yml b/ansible/host_vars/libvirt-debian-8/main.yml index 42bf6c3..6b5d645 100644 --- a/ansible/host_vars/libvirt-debian-8/main.yml +++ b/ansible/host_vars/libvirt-debian-8/main.yml @@ -1,6 +1,7 @@ --- projects: - base + - jenkins - libosinfo - libvirt - libvirt-glib @@ -12,3 +13,5 @@ projects: - osinfo-db-tools - virt-manager - virt-viewer + +jenkins_secret: '{{ vault_jenkins_secret }}' diff --git a/ansible/host_vars/libvirt-debian-8/vault.yml b/ansible/host_vars/libvirt-debian-8/vault.yml new file mode 100644 index 0000000..cbcc721 --- /dev/null +++ b/ansible/host_vars/libvirt-debian-8/vault.yml @@ -0,0 +1,10 @@ +$ANSIBLE_VAULT;1.1;AES256 +31336636633735633463343137643865656262633531623935353465353063396439333234303562 +3331353530306331363639333361643738613335366633350a386663646630636332623832616539 +62653433306466646133313531656634616361336436326339336338383163386161313535666338 +6164306633393130650a316163653432623665626261373762633730353461353739613038646564 +62363163646163393939393262373030356464353234663566616330336130656662656539393131 +65316537333837396663366337356238306530656166636439346461326534396331343364653030 +38313938353135323463613565303166363533373565336236376566653063643562353933343337 +31316134386430613538363830396562393631633835643761386631363663306165343632656333 +3039 diff --git a/ansible/host_vars/libvirt-debian-9/main.yml b/ansible/host_vars/libvirt-debian-9/main.yml index ff28698..f28f42b 100644 --- a/ansible/host_vars/libvirt-debian-9/main.yml +++ b/ansible/host_vars/libvirt-debian-9/main.yml @@ -1,6 +1,7 @@ --- projects: - base + - jenkins - libosinfo - libvirt - libvirt-glib @@ -14,3 +15,5 @@ projects: - osinfo-db-tools - virt-manager - virt-viewer + +jenkins_secret: '{{ vault_jenkins_secret }}' diff --git a/ansible/host_vars/libvirt-debian-9/vault.yml b/ansible/host_vars/libvirt-debian-9/vault.yml new file mode 100644 index 0000000..5401e48 --- /dev/null +++ b/ansible/host_vars/libvirt-debian-9/vault.yml @@ -0,0 +1,10 @@ +$ANSIBLE_VAULT;1.1;AES256 +35356363663965366162643430613930363765333137623438663033616536313862323331336566 +6162343336636435346438363131663138376433633366650a383366303037346633363539396161 +38623533343238656238303066356465393733616136653330376330623735346435643630336336 +3666613962333736390a383731626161613836373330373465313834343638383838393334323232 +63636631666431666437323934383363353333653534393261343236663334646166313134353461 +36613538373566306365373466666235656330343330323761626534363361363134616430643539 +63333230333535386264383466303665663436333265366231336132316366353633613561313166 +39343339336231336564363131323234636363373933306636393462373939333562323731613761 +6435 diff --git a/ansible/host_vars/libvirt-fedora-25/main.yml b/ansible/host_vars/libvirt-fedora-25/main.yml index 8d3b26f..5bbbf15 100644 --- a/ansible/host_vars/libvirt-fedora-25/main.yml +++ b/ansible/host_vars/libvirt-fedora-25/main.yml @@ -1,6 +1,7 @@ --- projects: - base + - jenkins - libosinfo - libvirt - libvirt-cim @@ -15,3 +16,5 @@ projects: - osinfo-db-tools - virt-manager - virt-viewer + +jenkins_secret: '{{ vault_jenkins_secret }}' diff --git a/ansible/host_vars/libvirt-fedora-25/vault.yml b/ansible/host_vars/libvirt-fedora-25/vault.yml new file mode 100644 index 0000000..e6f9f06 --- /dev/null +++ b/ansible/host_vars/libvirt-fedora-25/vault.yml @@ -0,0 +1,10 @@ +$ANSIBLE_VAULT;1.1;AES256 +36636231353137663930643139343034663530336632313563376239316266343562353230376362 +6666663536353832623438346531656338366636623361350a613761386566643932396331663633 +35666261383661333635656664616661633863633362373564333262303863366166323534376433 +6632633736326537360a346231633862643366333433383838393331353535373634303837633563 +32333838326136303339633739383061316638646663343364326563666638396664353965623462 +30303839386235616236386230343738313031356338376135333933376566306132373862303039 +39653665616132383135646663656233343031396339663437323939646132316665613862613461 +36333235623563346136353836656336323435333836326463373235393362616430346230633665 +6266 diff --git a/ansible/host_vars/libvirt-fedora-26/main.yml b/ansible/host_vars/libvirt-fedora-26/main.yml index 8d3b26f..5bbbf15 100644 --- a/ansible/host_vars/libvirt-fedora-26/main.yml +++ b/ansible/host_vars/libvirt-fedora-26/main.yml @@ -1,6 +1,7 @@ --- projects: - base + - jenkins - libosinfo - libvirt - libvirt-cim @@ -15,3 +16,5 @@ projects: - osinfo-db-tools - virt-manager - virt-viewer + +jenkins_secret: '{{ vault_jenkins_secret }}' diff --git a/ansible/host_vars/libvirt-fedora-26/vault.yml b/ansible/host_vars/libvirt-fedora-26/vault.yml new file mode 100644 index 0000000..eb2375f --- /dev/null +++ b/ansible/host_vars/libvirt-fedora-26/vault.yml @@ -0,0 +1,10 @@ +$ANSIBLE_VAULT;1.1;AES256 +36373735366565623865626564663333663135643333626561373661366564316439383537373537 +3130363864626664346430636335353166626466663937630a353061386162363264333839313431 +64613465333431633736326535646561383061623631623036656361613234303132663530636330 +3530303366393939630a306631366463643463393039643332646239633862353866303939643461 +37643662663336383338653631363835383936316535323639356538653534303936636465346366 +66303465613065383639333734373961636261303535313065316131663962623430656666653439 +39613865326666363635643837363064323330306261666436373532386339666435373931386433 +64613636353566336466393266313534616666373165626539653632356430353930373961373835 +3631 diff --git a/ansible/host_vars/libvirt-fedora-rawhide/main.yml b/ansible/host_vars/libvirt-fedora-rawhide/main.yml index 8d3b26f..5bbbf15 100644 --- a/ansible/host_vars/libvirt-fedora-rawhide/main.yml +++ b/ansible/host_vars/libvirt-fedora-rawhide/main.yml @@ -1,6 +1,7 @@ --- projects: - base + - jenkins - libosinfo - libvirt - libvirt-cim @@ -15,3 +16,5 @@ projects: - osinfo-db-tools - virt-manager - virt-viewer + +jenkins_secret: '{{ vault_jenkins_secret }}' diff --git a/ansible/host_vars/libvirt-fedora-rawhide/vault.yml b/ansible/host_vars/libvirt-fedora-rawhide/vault.yml new file mode 100644 index 0000000..2702f34 --- /dev/null +++ b/ansible/host_vars/libvirt-fedora-rawhide/vault.yml @@ -0,0 +1,10 @@ +$ANSIBLE_VAULT;1.1;AES256 +62663638306366333136666338336465333961353933613538363563666562316466323864363137 +6362356336663762393734326336363765316334663661650a656436356533623165363330626433 +31373962316231363039356261326337376263656634363463343264333438663535396337633433 +6562663563626637300a303932343263663463666265313737663536373632326330633132386336 +63616466363336373666393137613464383864333065306333346133633965373463653264666363 +34326134303962396130646434373738316134323061386466623035616363626235353037343662 +63616466333930623563363632656662303063353431666432353763326433653364363963303033 +65633166323837313438393134303861663434643336616331313063623739396138343930643364 +6136 diff --git a/ansible/host_vars/libvirt-freebsd-10/main.yml b/ansible/host_vars/libvirt-freebsd-10/main.yml index 69b172c..e993a66 100644 --- a/ansible/host_vars/libvirt-freebsd-10/main.yml +++ b/ansible/host_vars/libvirt-freebsd-10/main.yml @@ -8,6 +8,7 @@ sudo: /usr/local/bin/sudo projects: - base + - jenkins - libosinfo - libvirt - libvirt-glib @@ -20,3 +21,5 @@ projects: - osinfo-db-tools - virt-manager - virt-viewer + +jenkins_secret: '{{ vault_jenkins_secret }}' diff --git a/ansible/host_vars/libvirt-freebsd-10/vault.yml b/ansible/host_vars/libvirt-freebsd-10/vault.yml new file mode 100644 index 0000000..a3196f7 --- /dev/null +++ b/ansible/host_vars/libvirt-freebsd-10/vault.yml @@ -0,0 +1,10 @@ +$ANSIBLE_VAULT;1.1;AES256 +61386461653666613964333661643531393338396335343362646636616135306638383339646231 +3463356661623331393133316132333264396366613439300a633261353439383230613264653032 +36366166373333636235363964366566393165313239373138306339653038373639376361656635 +3362343935386538380a396261373664633837333364346435353034343663306235363561356265 +34383164643337366439393332393866653835353731393439303236643263346361373133623635 +66623939393436333838613363613936333733386235386332386538346461333331343837323061 +37613136333763643837626363353432626630336434383934353465633131303561633235366634 +65396435316564323936303331396236313137316532666163656131356339373633303063346432 +3435 diff --git a/ansible/host_vars/libvirt-freebsd-11/main.yml b/ansible/host_vars/libvirt-freebsd-11/main.yml index 69b172c..e993a66 100644 --- a/ansible/host_vars/libvirt-freebsd-11/main.yml +++ b/ansible/host_vars/libvirt-freebsd-11/main.yml @@ -8,6 +8,7 @@ sudo: /usr/local/bin/sudo projects: - base + - jenkins - libosinfo - libvirt - libvirt-glib @@ -20,3 +21,5 @@ projects: - osinfo-db-tools - virt-manager - virt-viewer + +jenkins_secret: '{{ vault_jenkins_secret }}' diff --git a/ansible/host_vars/libvirt-freebsd-11/vault.yml b/ansible/host_vars/libvirt-freebsd-11/vault.yml new file mode 100644 index 0000000..55a02e9 --- /dev/null +++ b/ansible/host_vars/libvirt-freebsd-11/vault.yml @@ -0,0 +1,10 @@ +$ANSIBLE_VAULT;1.1;AES256 +35366634666565336238303436346366323865633938643064353533376164383662376564373634 +3964303330333438336462326139356534656535356339660a646463373034313734636565613335 +37363335663133333361376665623438316332633434323666646663643166613637653966383833 +3464613638613465320a393766613131616634343839623130366464653431313833613865646336 +65663136346365623233363533323730666661323863356531373162303961343264376531626362 +37346366366439643937346264376266643030623464333032353237303635343532303336373730 +37353564306663623361646239666234323038663162643436623136313033356562326561373337 +64333633343263613636666231393437356630343362633935623837353135303364343733326136 +3933 diff --git a/ansible/host_vars/libvirt-ubuntu-12/main.yml b/ansible/host_vars/libvirt-ubuntu-12/main.yml index 4d53bb3..acb4876 100644 --- a/ansible/host_vars/libvirt-ubuntu-12/main.yml +++ b/ansible/host_vars/libvirt-ubuntu-12/main.yml @@ -1,4 +1,7 @@ --- projects: - base + - jenkins - libvirt + +jenkins_secret: '{{ vault_jenkins_secret }}' diff --git a/ansible/host_vars/libvirt-ubuntu-12/vault.yml b/ansible/host_vars/libvirt-ubuntu-12/vault.yml new file mode 100644 index 0000000..0e4f11a --- /dev/null +++ b/ansible/host_vars/libvirt-ubuntu-12/vault.yml @@ -0,0 +1,8 @@ +$ANSIBLE_VAULT;1.1;AES256 +31343061616436666138373261313733666434303431636233383766653637356532366664346434 +3430613264376461333233343839636138376363623837650a653566393532663133623139353932 +65373332626561613637393362663365643164396266633139643966336234323264653363376431 +3062343932353663660a313433383635363134383235663163663735326431386133653338363031 +62383038316164626563646438303565396135623735626261323139663265333162333562303237 +32313138663535363763383063303033333234396633313664353031666132316330313430663261 +626164653766633236633465373533303730 diff --git a/ansible/host_vars/libvirt-ubuntu-14/main.yml b/ansible/host_vars/libvirt-ubuntu-14/main.yml index 18b013d..05c05c6 100644 --- a/ansible/host_vars/libvirt-ubuntu-14/main.yml +++ b/ansible/host_vars/libvirt-ubuntu-14/main.yml @@ -1,6 +1,7 @@ --- projects: - base + - jenkins - libosinfo - libvirt - libvirt-perl @@ -9,3 +10,5 @@ projects: - osinfo-db-tools - virt-manager - virt-viewer + +jenkins_secret: '{{ vault_jenkins_secret }}' diff --git a/ansible/host_vars/libvirt-ubuntu-14/vault.yml b/ansible/host_vars/libvirt-ubuntu-14/vault.yml new file mode 100644 index 0000000..4d7021a --- /dev/null +++ b/ansible/host_vars/libvirt-ubuntu-14/vault.yml @@ -0,0 +1,8 @@ +$ANSIBLE_VAULT;1.1;AES256 +32386562363465636265666365656262313166663463306664363638336135396533336462323361 +6661383437306236376663353037363265623833333533300a613561383439393732623039336266 +61313235666437356338313434656361666666393061653461343535366436303734653237336439 +3936366333346634330a623062376433336165346534626563383439383263326639646338313036 +32306339646166393938333964623732626331373361386365653435346263623831613261656135 +37303830656566643832356264643237643931623866376435306433343433393537353634353130 +363933393966643163353137646638663065 diff --git a/ansible/host_vars/libvirt-ubuntu-16/main.yml b/ansible/host_vars/libvirt-ubuntu-16/main.yml index 7baecf7..4a3a0be 100644 --- a/ansible/host_vars/libvirt-ubuntu-16/main.yml +++ b/ansible/host_vars/libvirt-ubuntu-16/main.yml @@ -1,6 +1,7 @@ --- projects: - base + - jenkins - libosinfo - libvirt - libvirt-glib @@ -13,3 +14,5 @@ projects: - osinfo-db-tools - virt-manager - virt-viewer + +jenkins_secret: '{{ vault_jenkins_secret }}' diff --git a/ansible/host_vars/libvirt-ubuntu-16/vault.yml b/ansible/host_vars/libvirt-ubuntu-16/vault.yml new file mode 100644 index 0000000..b7968f7 --- /dev/null +++ b/ansible/host_vars/libvirt-ubuntu-16/vault.yml @@ -0,0 +1,8 @@ +$ANSIBLE_VAULT;1.1;AES256 +64623036353031653333316132333739656435303732333036633031646564396239633235356639 +3533353934636539353433623336313633663332666639380a626130353565623031303630333764 +36333861303561643336323566323035646164343964643839343862386463653462643265643461 +3461636431616630350a636630353137336634663539643835666466643639613864366561396365 +34653733616464303266303165326461623430643762376161626434323665376262393635656136 +33353135616364336366633231643466343563616665623633393762383662633136393632323633 +333631346631646166363536393932663932 diff --git a/ansible/site.yml b/ansible/site.yml index 907a35b..e6cf10d 100644 --- a/ansible/site.yml +++ b/ansible/site.yml @@ -18,3 +18,10 @@ loop_var: project when: - projects is defined + + # Configure the Jenkins agent + - include: tasks/jenkins.yml + when: + - projects is defined + # jenkins is a pseudo-project + - ( 'jenkins' in projects ) diff --git a/ansible/tasks/jenkins.yml b/ansible/tasks/jenkins.yml new file mode 100644 index 0000000..020277e --- /dev/null +++ b/ansible/tasks/jenkins.yml @@ -0,0 +1,59 @@ +--- +- name: Create Jenkins user account + user: + name: jenkins + comment: Jenkins + password: '*' + +- name: Download Jenkins agent + get_url: + url: https://ci.centos.org/jnlpJars/slave.jar + dest: /home/jenkins/slave.jar + owner: jenkins + group: jenkins + +- name: Figure out how to start Jenkins agent + set_fact: + use_rc_local: true + use_systemd: false + when: + - ( os_name == 'FreeBSD' or + ( os_name == 'CentOS' and os_version == '6' ) or + ( os_name == 'Ubuntu' and os_version == '12' ) or + ( os_name == 'Ubuntu' and os_version == '14' ) ) + +- name: Figure out how to start Jenkins agent + set_fact: + use_rc_local: false + use_systemd: true + when: + - use_rc_local is not defined + - use_systemd is not defined + +- name: Configure and enable Jenkins agent + lineinfile: + path: /etc/rc.local + create: yes + backup: yes + regexp: '^nohup.*jenkins.*java.*slave\.jar.*&$' + line: "nohup {{ sudo }} -u jenkins {{ bash }} -l -c '{{ java }} -jar /home/jenkins/slave.jar -jnlpUrl {{ jenkins_url }} -secret {{ jenkins_secret }}' >/var/log/jenkins.log 2>&1 &" + insertafter: EOF + when: + - use_rc_local + +- name: Configure Jenkins agent + template: + src: templates/jenkins.service.j2 + dest: /etc/systemd/system/jenkins.service + when: + - use_systemd + +- name: Reload systemd status + command: systemctl daemon-reload + when: + - use_systemd + +- name: Enable Jenkins agent + command: systemctl enable jenkins + when: + - use_systemd diff --git a/ansible/templates/jenkins.service.j2 b/ansible/templates/jenkins.service.j2 new file mode 100644 index 0000000..a7c8dcf --- /dev/null +++ b/ansible/templates/jenkins.service.j2 @@ -0,0 +1,14 @@ +[Unit] +Description=Jenkins agent +Wants=network.target +After=network.target + +[Service] +ExecStart={{ bash }} -l -c '{{ java }} -jar /home/jenkins/slave.jar -jnlpUrl {{ jenkins_url }} -secret {{ jenkins_secret }}' +User=jenkins +Group=jenkins +WorkingDirectory=/home/jenkins +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/ansible/vars/mappings.yml b/ansible/vars/mappings.yml index b775dfc..a660101 100644 --- a/ansible/vars/mappings.yml +++ b/ansible/vars/mappings.yml @@ -166,6 +166,14 @@ mappings: deb: open-iscsi rpm: iscsi-initiator-utils + java: + deb: openjdk-8-jre-headless + pkg: openjdk8-jre + rpm: java-1.8.0-openjdk-headless + Debian8: openjdk-7-jre-headless + Ubuntu12: openjdk-7-jre-headless + Ubuntu14: openjdk-7-jre-headless + libacl: deb: libacl1-dev rpm: libacl-devel diff --git a/ansible/vars/projects/jenkins.yml b/ansible/vars/projects/jenkins.yml new file mode 100644 index 0000000..509f71a --- /dev/null +++ b/ansible/vars/projects/jenkins.yml @@ -0,0 +1,3 @@ +--- +packages: + - java -- 2.13.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list