From bf49f3c648029dc556b417d6905aae3245763787 Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Tue, 15 Sep 2020 21:52:08 -0400 Subject: [PATCH] Create and use Jenkins user --- roles/jenkins/defaults/main.yml | 1 + roles/jenkins/tasks/main.yml | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/roles/jenkins/defaults/main.yml b/roles/jenkins/defaults/main.yml index a05629d..ec9b788 100644 --- a/roles/jenkins/defaults/main.yml +++ b/roles/jenkins/defaults/main.yml @@ -1,2 +1,3 @@ jenkins_name: jenkins +jenkins_user: jenkins jenkins_root: "/opt/{{ jenkins_name }}/jenkins_home" diff --git a/roles/jenkins/tasks/main.yml b/roles/jenkins/tasks/main.yml index 88c7109..3c2e2fe 100644 --- a/roles/jenkins/tasks/main.yml +++ b/roles/jenkins/tasks/main.yml @@ -1,3 +1,19 @@ +- name: Create Jenkins user + user: + name: "{{ jenkins_user }}" + state: present + shell: /bin/bash + skeleton: /etc/skel + generate_ssh_key: true + +- name: Set Jenkins authorized key + authorized_key: + user: jenkins + state: present + exclusive: true + key: "{{ jenkins_sshkey }}" + when: jenkins_sshkey is defined + - name: Install Ansible source template: src: ansible.list