Skip to content

Instantly share code, notes, and snippets.

@echo-devnull
Created February 27, 2018 09:42
Show Gist options
  • Save echo-devnull/4d13c8f8931d1e62823082a663a6bcc3 to your computer and use it in GitHub Desktop.
Save echo-devnull/4d13c8f8931d1e62823082a663a6bcc3 to your computer and use it in GitHub Desktop.
Creating a Jenkins User and automatically add the SSH key to github
- name: Setup Jenkins user
user:
name: jenkins
state: present
groups: docker,admin
generate_ssh_key: true
append: yes
comment: "Jenkins Slave User"
update_password: on_create
password: "$6$rounds=656000$tEpd0QsWMpIusdfgdgdfgdfgdfgdgdfgYWe6qhOxheJwsiDM/"
- name: Read SSH public key to authorize
shell: cat /home/jenkins/.ssh/id_rsa.pub
register: ssh_pub_key
- name: Authorize key with GitHub
local_action:
module: github_key
name: Access Key for Elect Jenkins Build Machine
token: 'dgdfgdfgfdgdfgdfgdfgdf'
pubkey: '{{ ssh_pub_key.stdout }}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment