|
| 1 | +--- |
| 2 | +# vim: set ft=ansible: |
| 3 | +# |
| 4 | +- name: OpenShift Ansible Installer Test |
| 5 | + hosts: all |
| 6 | + |
| 7 | + tasks: |
| 8 | + - name: Setup vars for templating the inventory, etc. |
| 9 | + set_fact: |
| 10 | + oo_ansible_user: "{{ cli_ansible_user | default(ansible_user) }}" |
| 11 | + oo_ansible_tag: "{{ cli_oo_ansible_tag | default('master') }}" |
| 12 | + oo_public_host: "{{ cli_oo_public_host | default(ansible_host) }}" |
| 13 | + # NOTE: If you intend to run the playbook against a host in the Amazon |
| 14 | + # EC2 enviroment, it has been reported that you will need to set the |
| 15 | + # 'cli_oo_host' variable to the interal IP address of your EC2 |
| 16 | + # instance. This can be done via the inventory file or on the command |
| 17 | + # line, like so: |
| 18 | + # |
| 19 | + # $ ansible-playbook -i inventory -e cli_oo_host=10.0.36.120 tests/openshift-ansible-testing/main.yml |
| 20 | + # |
| 21 | + oo_host: "{{ cli_oo_host | default(ansible_default_ipv4.address) }}" |
| 22 | + oo_release: "{{ cli_oo_release | default('1.5.1') }}" |
| 23 | + oo_py_interpreter: "{{ '-e ansible_python_interpreter=/usr/bin/python3' if ansible_distribution == 'Fedora' else '' }}" |
| 24 | + oo_skip_memory_check: "{{ '-e openshift_disable_check=memory_availability' if ansible_memtotal_mb|int < 8192 else '' }}" |
| 25 | + |
| 26 | + - name: Make temp directory of holding |
| 27 | + command: mktemp -d |
| 28 | + register: mktemp |
| 29 | + delegate_to: localhost |
| 30 | + |
| 31 | + - name: git clone openshift-ansible repo |
| 32 | + git: |
| 33 | + repo: "https://github.com/openshift/openshift-ansible.git" |
| 34 | + dest: "{{ mktemp.stdout }}" |
| 35 | + version: "{{ oo_ansible_tag }}" |
| 36 | + delegate_to: localhost |
| 37 | + |
| 38 | + - name: Template the inventory file |
| 39 | + template: |
| 40 | + src: "templates/cluster-inventory.j2" |
| 41 | + dest: "{{ mktemp.stdout }}/cluster-inventory" |
| 42 | + delegate_to: localhost |
| 43 | + |
| 44 | + - name: Run the openshift-ansible playbook |
| 45 | + command: "ansible-playbook -i cluster-inventory playbooks/byo/config.yml {{ oo_py_interpreter }} {{ oo_skip_memory_check }}" |
| 46 | + args: |
| 47 | + chdir: "{{ mktemp.stdout }}" |
| 48 | + delegate_to: localhost |
| 49 | + |
| 50 | + - name: Wait for 8443 to open up |
| 51 | + wait_for: |
| 52 | + port: 8443 |
| 53 | + delay: 60 |
| 54 | + |
| 55 | + # this may not be required |
| 56 | + - name: Add admin user to cluster-admin role |
| 57 | + command: /usr/local/bin/oadm policy add-cluster-role-to-user cluster-admin admin |
| 58 | + |
| 59 | + - name: Login to the cluster |
| 60 | + command: "/usr/local/bin/oc login -u admin -p OriginAdmin https://{{ oo_public_host }}:8443" |
| 61 | + |
| 62 | + # this is kind of a hack; sometimes need to wait (5m) for the pods |
| 63 | + - name: Verify pods are running |
| 64 | + command: /usr/local/bin/oc get pods -o jsonpath='{.items[*].status.phase}' |
| 65 | + register: pods |
| 66 | + until: pods.stdout == "Running Running Running" |
| 67 | + retries: 10 |
| 68 | + delay: 30 |
0 commit comments