Skip to content
This repository has been archived by the owner on Jul 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #19 from infOpen/devel
Browse files Browse the repository at this point in the history
Add credentials management
  • Loading branch information
achaussier committed Nov 22, 2015
2 parents ff1b1f8 + cb1a9e1 commit 6f99762
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ Follow the possible variables with their default values
# Plugins
jenkins_plugins : []

# Jenkins clouds
jenkins_main_cfg_clouds : []

# Jenkins credentials
jenkins_credentials : []

# API URLs
#---------
jenkins_api_plugins_list : >
Expand Down Expand Up @@ -473,6 +479,38 @@ Follow the possible variables with their default values
retention_strategy:
idle_minutes: 10

### How configure credentials

This is an example of YAML structure to create credentials for Jenkins.
WARNING : This will clear old previous credentials !

This example create two accounts, one with SSH auth and one with password auth.

jenkins_credentials:
domainCredentials:
- domain:
name: "my-credential-domain"
description: "My beautiful credential domain"
credentials:
- scope: "GLOBAL"
id: "my-id"
username: "foo"
description: "foobar"
privateKeySource:
value: 1
privateKeyFile: "/my/key.ssh"
stapler-class: "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey$FileOnMasterPrivateKeySource"
passphrase: "coucou"
stapler-class: "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey"
kind: "com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey"
- scope: "GLOBAL"
id: "my-id-2"
username: "bar"
description: "foobar"
password: "big-password!"
stapler-class: "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"
kind: "com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl"

### Specific vars values for Debian family

jenkins_repository_file_prefix : "/etc/apt/sources.list.d"
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ jenkins_plugins : []
# Jenkins clouds
jenkins_main_cfg_clouds : []

# Jenkins credentials
jenkins_credentials : []

# API URLs
#---------
jenkins_api_plugins_list : >
Expand Down
7 changes: 7 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@
- jenkins
- configure

- name : Create credentials
include : "{{ role_path }}/tasks/manage_credentials.yml"
when : jenkins_credentials
tags :
- jenkins
- configure

12 changes: 12 additions & 0 deletions tasks/manage_credentials.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

# These tasks manage credentials

- name : Create credentials (/!\ This reset old credentials)
uri :
url : "{{ jenkins_base_url }}/credentials/configSubmit"
method: POST
body: "json={{ jenkins_credentials | to_json }}"
HEADER_Content-Type : "application/x-www-form-urlencoded"
status_code: "200,302"

0 comments on commit 6f99762

Please sign in to comment.