Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- # ansible-playbook insert-htpasswd-identity-ocp.yaml --extra-vars '{"master_host_group":"masters","users":["user1","user2"],"password":"password"}'
- - hosts: localhost
- connection: local
- become: false
- tasks:
- - name: Add users to htpasswd file
- htpasswd:
- create: true
- path: users.htpasswd
- name: "{{ item }}"
- password: "{{ password }}"
- mode: 0640
- with_items: "{{ users }}"
- - hosts: "{{ master_host_group }}"
- become: true
- tasks:
- - name: Copy htpasswd file to masters
- copy:
- src: users.htpasswd
- dest: /etc/origin/master/users.htpasswd
- - name: Add htpasswd identity provider stanza to master-config.yaml
- blockinfile:
- dest: /etc/origin/master/master-config.yaml
- state: present
- insertafter: "$ identityProviders:\n^"
- block: |
- - name: htpasswd
- challenge: true
- login: true
- mappingMethod: claim
- provider:
- apiVersion: v1
- kind: HTPasswdPasswordIdentityProvider
- file: /etc/origin/master/users.htpasswd
- - name: Restart OpenShift Master API
- systemd:
- name: atomic-openshift-master-api.service
- state: restarted
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement