The jenkins-cli is used to initially configure the Jenkins service. As
of recent versions, however, anonymous cli access isn't allowed unless
useSecurity is set to false in Jenkins' config.xml. This opens Jenkins
to the world of course.
By creating some firewall rules, we can just disable nginx, turn of
auth, allow only localhost access to port 8080 and safely make changes using
jenkins-cli.
Signed-off-by: David Galloway <dgallowa@redhat.com>
tags:
- letsencrypt
+- include: ufw.yml
+ tags:
+ - ufw
+
- name: Install Jenkins
apt:
name: jenkins
--- /dev/null
+---
+- name: install ufw
+ apt:
+ name: ufw
+ state: latest
+
+- name: only listen to localhost on port 8080
+ ufw:
+ port: 8080
+ src: 127.0.0.1
+ rule: allow
+
+- name: allow custom ssh, http, https, and JNLP slave port
+ ufw:
+ port: "{{ item }}"
+ rule: allow
+ with_items:
+ - 2222
+ - 80
+ - 443
+ - 49187
+
+- name: reload ufw
+ ufw:
+ state: reloaded
+
+- name: start ufw
+ ufw:
+ state: enabled