serviceaccount.yml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ---
  2. - name: Create temporary directory for admin kubeconfig
  3. command: mktemp -u /tmp/openshift-ansible-XXXXXXX.kubeconfig
  4. register: nuage_tmp_conf_mktemp
  5. changed_when: False
  6. - set_fact:
  7. nuage_tmp_conf: "{{ nuage_tmp_conf_mktemp.stdout }}"
  8. - name: Copy Configuration to temporary conf
  9. command: >
  10. cp {{ openshift.common.config_base }}/master/admin.kubeconfig {{nuage_tmp_conf}}
  11. changed_when: false
  12. - name: Create Admin Service Account
  13. oc_serviceaccount:
  14. kubeconfig: "{{ openshift_master_config_dir }}/admin.kubeconfig"
  15. name: nuage
  16. namespace: default
  17. state: present
  18. - name: Configure role/user permissions
  19. command: >
  20. {{ openshift.common.client_binary }} adm {{item}}
  21. --config={{ nuage_tmp_conf }}
  22. with_items: "{{nuage_tasks}}"
  23. register: osnuage_perm_task
  24. failed_when: "'the object has been modified' not in osnuage_perm_task.stderr and osnuage_perm_task.rc != 0"
  25. changed_when: osnuage_perm_task.rc == 0
  26. - name: Generate the node client config
  27. command: >
  28. {{ openshift.common.client_binary }} adm create-api-client-config
  29. --certificate-authority={{ openshift_master_ca_cert }}
  30. --client-dir={{ cert_output_dir }}
  31. --master={{ openshift.master.api_url }}
  32. --public-master={{ openshift.master.api_url }}
  33. --signer-cert={{ openshift_master_ca_cert }}
  34. --signer-key={{ openshift_master_ca_key }}
  35. --signer-serial={{ openshift_master_ca_serial }}
  36. --basename='nuage'
  37. --user={{ nuage_service_account }}
  38. - name: Clean temporary configuration file
  39. command: >
  40. rm -f {{nuage_tmp_conf}}
  41. changed_when: false