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