serviceaccount.yml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. shell: >
  14. echo {{ nuage_service_account_config | to_json | quote }} |
  15. {{ openshift.common.client_binary }} create
  16. -n default
  17. --config={{nuage_tmp_conf}}
  18. -f -
  19. register: osnuage_create_service_account
  20. failed_when: "'already exists' not in osnuage_create_service_account.stderr and osnuage_create_service_account.rc != 0"
  21. changed_when: osnuage_create_service_account.rc == 0
  22. - name: Configure role/user permissions
  23. command: >
  24. {{ openshift.common.admin_binary }} {{item}}
  25. --config={{nuage_tmp_conf}}
  26. with_items: "{{nuage_tasks}}"
  27. register: osnuage_perm_task
  28. failed_when: "'already exists' not in osnuage_perm_task.stderr and osnuage_perm_task.rc != 0"
  29. changed_when: osnuage_perm_task.rc == 0
  30. - name: Generate the node client config
  31. command: >
  32. {{ openshift.common.admin_binary }} create-api-client-config
  33. --certificate-authority={{ openshift_master_ca_cert }}
  34. --client-dir={{ cert_output_dir }}
  35. --master={{ openshift.master.api_url }}
  36. --public-master={{ openshift.master.api_url }}
  37. --signer-cert={{ openshift_master_ca_cert }}
  38. --signer-key={{ openshift_master_ca_key }}
  39. --signer-serial={{ openshift_master_ca_serial }}
  40. --basename='nuage'
  41. --user={{ nuage_service_account }}
  42. - name: Clean temporary configuration file
  43. command: >
  44. rm -f {{nuage_tmp_conf}}
  45. changed_when: false