ansible-role-jenkins icon indicating copy to clipboard operation
ansible-role-jenkins copied to clipboard

Initalise Jenkins with systemd instead of init

Open matthewrfennell opened this issue 2 years ago • 5 comments

Fixes #351

matthewrfennell avatar Jun 04 '22 15:06 matthewrfennell

I have tried the changes suggested in this PR and they work as expected.

presPetkov avatar Jun 23 '22 20:06 presPetkov

For some reason it doesn't seem like this is running the CI tests — this PR looks acceptable (though will require a major version bump since there are some breaking changes), but I want to make sure we cover the CI test cases (like alternate HTTP port) before merging.

geerlingguy avatar Jul 27 '22 14:07 geerlingguy

Sounds good, give me a shout if you need anything from my end

ghost avatar Jul 27 '22 21:07 ghost

I checked role from this PR. It is ok. I can write inventory and playbook if you need.

patsevanton avatar Jul 30 '22 05:07 patsevanton

I try add env CASC_JENKINS_CONFIG to inventory. It is not work.

    jenkins_init_changes:
      - option: "CASC_JENKINS_CONFIG"
        value: "/var/lib/jenkins/jcasc/"

image

Show systemctl service:

root@jenkins:~# systemctl cat jenkins.service | grep -v "#" | grep -v "^$"
[Unit]
Description=Jenkins Continuous Integration Server
Requires=network.target
After=network.target
[Service]
Type=notify
NotifyAccess=main
ExecStart=/usr/bin/jenkins
Restart=on-failure
SuccessExitStatus=143
User=jenkins
Group=jenkins
Environment="JENKINS_HOME=/var/lib/jenkins"
WorkingDirectory=/var/lib/jenkins
Environment="JENKINS_WEBROOT=%C/jenkins/war"
Environment="JAVA_OPTS=-Djava.awt.headless=true"
Environment="JENKINS_PORT=8080"
[Install]
WantedBy=multi-user.target
[Service]
Environment="CASC_JENKINS_CONFIG=/var/lib/jenkins/jcasc/"

If i add this code to inventory:

    jenkins_init_changes:
      - option: "JENKINS_OPTS"
        value: "{{ jenkins_options }}"
      - option: "JAVA_OPTS"
        value: "{{ jenkins_java_options }}"
      - option: "JENKINS_HOME"
        value: "{{ jenkins_home }}"
      - option: "JENKINS_PREFIX"
        value: "{{ jenkins_url_prefix }}"
      - option: "JENKINS_PORT"
        value: "{{ jenkins_http_port }}"
      - option: "CASC_JENKINS_CONFIG"
        value: "/var/lib/jenkins/jcasc/"

then will not Customize Jenkins and systemctl service:

root@jenkins:~# systemctl cat jenkins.service | grep -v "#" | grep -v "^$"
[Unit]
Description=Jenkins Continuous Integration Server
Requires=network.target
After=network.target
[Service]
Type=notify
NotifyAccess=main
ExecStart=/usr/bin/jenkins
Restart=on-failure
SuccessExitStatus=143
User=jenkins
Group=jenkins
Environment="JENKINS_HOME=/var/lib/jenkins"
WorkingDirectory=/var/lib/jenkins
Environment="JENKINS_WEBROOT=%C/jenkins/war"
Environment="JAVA_OPTS=-Djava.awt.headless=true"
Environment="JENKINS_PORT=8080"
[Install]
WantedBy=multi-user.target
[Service]
Environment="JENKINS_OPTS="
Environment="JAVA_OPTS=-Djenkins.install.runSetupWizard=false"
Environment="JENKINS_HOME=/var/lib/jenkins"
Environment="JENKINS_PREFIX="
Environment="JENKINS_PORT=8080"
Environment="CASC_JENKINS_CONFIG=/var/lib/jenkins/jcasc/"

patsevanton avatar Jul 31 '22 07:07 patsevanton

👍

rds13 avatar Aug 26 '22 14:08 rds13

Merging this so it will unblock other work towards getting the role working again with more recent Jenkins versions. It might break some people's configurations, so when I release a tag it will be a major version bump.

geerlingguy avatar Aug 30 '22 14:08 geerlingguy