homelab/roles/jenkins/tasks/agent.yml

32 lines
692 B
YAML

- name: Create Jenkins user
ansible.builtin.user:
name: "{{ jenkins_user }}"
state: present
shell: /bin/bash
skeleton: /etc/skel
generate_ssh_key: true
- name: Set Jenkins authorized key
ansible.posix.authorized_key:
user: jenkins
state: present
exclusive: true
key: "{{ jenkins_sshkey }}"
- name: Give Jenkins user passwordless sudo
ansible.builtin.template:
src: jenkins_sudoers.j2
dest: /etc/sudoers.d/{{ jenkins_user }}
validate: "visudo -cf %s"
mode: 0440
- name: Install Ansible
ansible.builtin.apt:
name: ansible
state: present
- name: Install Java
ansible.builtin.apt:
name: default-jre
state: present