Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. ---
  2. # ansible-playbook insert-htpasswd-identity-ocp.yaml --extra-vars '{"master_host_group":"masters","users":["user1","user2"],"password":"password"}'
  3. - hosts: localhost
  4. connection: local
  5. become: false
  6. tasks:
  7. - name: Add users to htpasswd file
  8. htpasswd:
  9. create: true
  10. path: users.htpasswd
  11. name: "{{ item }}"
  12. password: "{{ password }}"
  13. mode: 0640
  14. with_items: "{{ users }}"
  15.  
  16. - hosts: "{{ master_host_group }}"
  17. become: true
  18. tasks:
  19. - name: Copy htpasswd file to masters
  20. copy:
  21. src: users.htpasswd
  22. dest: /etc/origin/master/users.htpasswd
  23. - name: Add htpasswd identity provider stanza to master-config.yaml
  24. blockinfile:
  25. dest: /etc/origin/master/master-config.yaml
  26. state: present
  27. insertafter: "$ identityProviders:\n^"
  28. block: |
  29. - name: htpasswd
  30. challenge: true
  31. login: true
  32. mappingMethod: claim
  33. provider:
  34. apiVersion: v1
  35. kind: HTPasswdPasswordIdentityProvider
  36. file: /etc/origin/master/users.htpasswd
  37. - name: Restart OpenShift Master API
  38. systemd:
  39. name: atomic-openshift-master-api.service
  40. state: restarted
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement