diff --git a/allinone.yml b/allinone.yml index ddaab51..ac3a179 100644 --- a/allinone.yml +++ b/allinone.yml @@ -12,3 +12,9 @@ # Launch the OpenShift Installer Playbook - include: "./openshift-ansible/playbooks/byo/config.yml" + + - name: Customize the OpenShift installation + hosts: allinone + become: yes + roles: + - { name: 'hostpath-provisioner', tags: 'hostpath-provisioner' } diff --git a/roles/hostpath-provisioner/tasks/main.yml b/roles/hostpath-provisioner/tasks/main.yml new file mode 100644 index 0000000..8841881 --- /dev/null +++ b/roles/hostpath-provisioner/tasks/main.yml @@ -0,0 +1,30 @@ +--- + + - name: Create an empty hostpath_provisioner_options variable if it does not exist + set_fact: + hostpath_provisioner_options: {} + when: hostpath_provisioner_options is not defined + tags: vars + + - name: Provision default values for the hostpath_provisioner_options + set_fact: + hostpath_provisioner_options: "{{ hostpath_provisioner_default_options|combine(hostpath_provisioner_options) }}" + tags: vars + + - name: Create a directory for the hostpath-provisioner + file: state=directory path={{ hostpath_provisioner_options.path }} owner=root group=root mode=0777 setype=svirt_sandbox_file_t + + - name: Checkout the hostpath-provisioner GIT Repository + git: dest={{ hostpath_provisioner_options.git_checkout_path }} repo={{ hostpath_provisioner_options.git_repo_url }} + become: no + + - name: Process the OpenShift Template + shell: oc process -f setup/hostpath-provisioner-template.yaml -p "HOSTPATH_TO_USE={{ hostpath_provisioner_options.path }}" -p "TARGET_NAMESPACE={{ hostpath_provisioner_options.target_namespace }}" -p "HOSTPATH_PROVISIONER_IMAGE={{ hostpath_provisioner_options.docker_image }}" > objects.json + args: + chdir: "{{ hostpath_provisioner_options.git_checkout_path }}" + become: no + + - name: Create the OpenShift objects for the hostpath-provisioner + command: oc create -f objects.json + args: + chdir: "{{ hostpath_provisioner_git_checkout_path }}" diff --git a/roles/hostpath-provisioner/vars/main.yml b/roles/hostpath-provisioner/vars/main.yml new file mode 100644 index 0000000..3edd09e --- /dev/null +++ b/roles/hostpath-provisioner/vars/main.yml @@ -0,0 +1,8 @@ +--- + + hostpath_provisioner_default_options: + path: /var/openshift + git_checkout_path: /home/{{ ansible_user }}/OpenShift-HostPath-Provisioner + git_repo_url: https://github.com/nmasse-itix/OpenShift-HostPath-Provisioner.git + target_namespace: default + docker_image: john/openshift-hostpath-provisioner:latest