From a1e5739f5b0a84164f8cbc5c2170999e6259eaed Mon Sep 17 00:00:00 2001 From: root Date: Wed, 20 May 2020 15:49:18 +0200 Subject: [PATCH 1/2] Added examples and check on LoadBalancer --- defaults/main.yml | 3 ++- .../{ => inventory}/inventory-fcos-grub.yml | 0 .../inventory-fcos-netinstall.yml | 0 .../inventory-fcos-template.yml | 0 docs/examples/playbook/create_infra.yml | 5 +++++ docs/examples/playbook/recreate.yml | 14 ++++++++++++ tasks/02-check_lb.yml | 22 +++++++++++++++++++ tasks/main.yml | 4 +++- 8 files changed, 46 insertions(+), 2 deletions(-) rename docs/examples/{ => inventory}/inventory-fcos-grub.yml (100%) rename docs/examples/{ => inventory}/inventory-fcos-netinstall.yml (100%) rename docs/examples/{ => inventory}/inventory-fcos-template.yml (100%) create mode 100644 docs/examples/playbook/create_infra.yml create mode 100644 docs/examples/playbook/recreate.yml create mode 100644 tasks/02-check_lb.yml diff --git a/defaults/main.yml b/defaults/main.yml index 6dcf152..86b16f8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -145,7 +145,8 @@ ocp_vm_create_vm: True # Enable/Disable this portion of role ocp_vm_install_client: True # Enable/Disable this portion of role ocp_vm_power_state: poweredon dns_fail_is_not_fatal: False # Ignore all DNS checks (You should nod ignore this kind of errors) -ptr_fail_is_not_fatal: True # Using iPXE PTR should not be a problem. +ptr_fail_is_not_fatal: False # Using iPXE PTR should not be a problem. +lb_fail_is_not_fatal: False # Using iPXE PTR should not be a problem. checks_only: False # Do the Checks and exit diff --git a/docs/examples/inventory-fcos-grub.yml b/docs/examples/inventory/inventory-fcos-grub.yml similarity index 100% rename from docs/examples/inventory-fcos-grub.yml rename to docs/examples/inventory/inventory-fcos-grub.yml diff --git a/docs/examples/inventory-fcos-netinstall.yml b/docs/examples/inventory/inventory-fcos-netinstall.yml similarity index 100% rename from docs/examples/inventory-fcos-netinstall.yml rename to docs/examples/inventory/inventory-fcos-netinstall.yml diff --git a/docs/examples/inventory-fcos-template.yml b/docs/examples/inventory/inventory-fcos-template.yml similarity index 100% rename from docs/examples/inventory-fcos-template.yml rename to docs/examples/inventory/inventory-fcos-template.yml diff --git a/docs/examples/playbook/create_infra.yml b/docs/examples/playbook/create_infra.yml new file mode 100644 index 0000000..3867f02 --- /dev/null +++ b/docs/examples/playbook/create_infra.yml @@ -0,0 +1,5 @@ +--- +- hosts: all + remote_user: root + roles: + - openshift4_vmware_infra_provisioner diff --git a/docs/examples/playbook/recreate.yml b/docs/examples/playbook/recreate.yml new file mode 100644 index 0000000..7477cdf --- /dev/null +++ b/docs/examples/playbook/recreate.yml @@ -0,0 +1,14 @@ +--- +- hosts: all + vars: + ocp_vm_cleanup: True + remote_user: root + roles: + - openshift4_vmware_infra_provisioner + +- hosts: all + vars: + ocp_vm_cleanup: False + remote_user: root + roles: + - openshift4_vmware_infra_provisioner diff --git a/tasks/02-check_lb.yml b/tasks/02-check_lb.yml new file mode 100644 index 0000000..7f903cd --- /dev/null +++ b/tasks/02-check_lb.yml @@ -0,0 +1,22 @@ +#ansible-configured + +- name: Check that the load balancer ports are open + wait_for: + host: '{{ item.host }}' + port: '{{ item.port }}' + connect_timeout: 1 + timeout: 1 + ignore_errors: "{{lb_fail_is_not_fatal}}" + with_items: + - host: "api.{{ocp_installer.clustername}}.{{ocp_installer.basedomain}}" + port: 6443 + - host: "api.{{ocp_installer.clustername}}.{{ocp_installer.basedomain}}" + port: 22623 + - host: "api-int.{{ocp_installer.clustername}}.{{ocp_installer.basedomain}}" + port: 6443 + - host: "api-int.{{ocp_installer.clustername}}.{{ocp_installer.basedomain}}" + port: 22623 + - host: "myapp.apps.{{ocp_installer.clustername}}.{{ocp_installer.basedomain}}" + port: 443 + - host: "myapp.apps.{{ocp_installer.clustername}}.{{ocp_installer.basedomain}}" + port: 80 diff --git a/tasks/main.yml b/tasks/main.yml index 6334061..428130e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,7 +9,9 @@ when: - not ocp_vm_cleanup|bool - ocp_vm_check_env|bool - include_tasks: 01-check_dns.yml + block: + - include_tasks: 01-check_dns.yml + - include_tasks: 02-check_lb.yml - name: Prepare WebServer when: From 3f349063e75d7e4f2c17d6f760ce26702b6be47b Mon Sep 17 00:00:00 2001 From: root Date: Wed, 20 May 2020 15:58:49 +0200 Subject: [PATCH 2/2] More examples and removed orfaned tasks --- .../inventory/inventory-rhcos-grub.yml | 118 +++++++++++++++++ .../inventory/inventory-rhcos-netinstall.yml | 121 ++++++++++++++++++ .../inventory/inventory-rhcos-template.yml | 115 +++++++++++++++++ tasks/41-transpile.yml | 10 +- tasks/90-debugmsg.yml | 4 - 5 files changed, 355 insertions(+), 13 deletions(-) create mode 100644 docs/examples/inventory/inventory-rhcos-grub.yml create mode 100644 docs/examples/inventory/inventory-rhcos-netinstall.yml create mode 100644 docs/examples/inventory/inventory-rhcos-template.yml delete mode 100644 tasks/90-debugmsg.yml diff --git a/docs/examples/inventory/inventory-rhcos-grub.yml b/docs/examples/inventory/inventory-rhcos-grub.yml new file mode 100644 index 0000000..5f1a225 --- /dev/null +++ b/docs/examples/inventory/inventory-rhcos-grub.yml @@ -0,0 +1,118 @@ +# ansible-configured +--- + # defaults file for ocp_vm + haproxy: + hosts: + bastion.ocp.mydomain.local + webserver: + hosts: + bastion.ocp.mydomain.local + all: + vars: + + enable_reservation: False # Don't want to reserve CPU for now + cpu_biggest: 2100 # 2.1GHZ + + vcenter: + host: vcenter.mydomain.local + user: administrator@vsphere.local + password: 'FILLME' + datacenter: Datacenter01 + folder: OCP + validate_certs: no + datastore: "DATASTORE" + + ocp_installer: + basedomain: mydomain.local + clustername: ocp + pullsecret: 'FILLME' + sshkey: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}" + install_type: rhcos # fedoracos | rhcos + clients: https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz + installer: https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-install-linux.tar.gz + install_method: grub + template: "rhcos-4.4.3-x86_64-vmware.x86_64" + + hosts_defaults: + network: + name: VM Network + mask: 255.255.255.0 + gw: 192.168.0.1 + dns: + - 192.168.0.2 + - 192.168.1.2 + - 192.168.1.3 + generic: + memory_mb: 16384 + num_cpus: 4 + num_cpu_cores_per_socket: 1 + mem_limit: 16384 + mem_reservation: 0 + disk: 120 + memory_reservation_lock: False + guest_id: other4xLinux64Guest + ignition: none + nested_virt: True + master: + memory_mb: 16384 + num_cpus: 4 + num_cpu_cores_per_socket: 1 + mem_limit: 16384 + mem_reservation: 0 + disk: 120 + memory_reservation_lock: False + guest_id: coreos64Guest + ignition: master.ign + nested_virt: True + + bootstrap: + memory_mb: 16384 + num_cpus: 4 + num_cpu_cores_per_socket: 1 + mem_limit: 16384 + mem_reservation: 0 + disk: 120 + memory_reservation_lock: False + guest_id: coreos64Guest + ignition: bootstrap.ign + nested_virt: True + + worker: + memory_mb: 8192 + num_cpus: 4 + num_cpu_cores_per_socket: 1 + mem_limit: 8192 + mem_reservation: 0 + disk: 120 + memory_reservation_lock: False + guest_id: coreos64Guest + ignition: worker.ign + nested_virt: True + + + + vm_hosts: + - hostname: bootstrap.ocp.mydomain.local + annotation: bootstrap + type: bootstrap + network: + ip: 192.168.0.187 + - hostname: master1.ocp.mydomain.local + type: master + network: + ip: 192.168.0.180 + - hostname: master2.ocp.mydomain.local + type: master + network: + ip: 192.168.0.181 + - hostname: master3.ocp.mydomain.local + type: master + network: + ip: 192.168.0.182 + - hostname: worker1.ocp.mydomain.local + type: worker + network: + ip: 192.168.0.183 + + + \ No newline at end of file diff --git a/docs/examples/inventory/inventory-rhcos-netinstall.yml b/docs/examples/inventory/inventory-rhcos-netinstall.yml new file mode 100644 index 0000000..f9755b5 --- /dev/null +++ b/docs/examples/inventory/inventory-rhcos-netinstall.yml @@ -0,0 +1,121 @@ +# ansible-configured +--- + # defaults file for ocp_vm + haproxy: + hosts: + bastion.ocp.mydomain.local + webserver: + hosts: + bastion.ocp.mydomain.local + all: + vars: + + enable_reservation: False # Don't want to reserve CPU for now + cpu_biggest: 2100 # 2.1GHZ + + vcenter: + host: vcenter.mydomain.local + user: administrator@vsphere.local + password: 'FILLME' + datacenter: Datacenter01 + folder: OCP + validate_certs: no + datastore: "DATASTORE" + + ocp_installer: + basedomain: mydomain.local + clustername: ocp + pullsecret: 'FILLME' + sshkey: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}" + install_type: rhcos # fedoracos | rhcos + kernel: https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/latest/latest/rhcos-4.4.3-x86_64-installer-kernel-x86_64 + initrd: https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/latest/latest/rhcos-4.4.3-x86_64-installer-initramfs.x86_64.img + coreos_image: https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/latest/latest/rhcos-4.4.3-x86_64-metal.x86_64.raw.gz + clients: https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz + installer: https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-install-linux.tar.gz + coreos_sha256: https://mirror.openshift.com/pub/openshift-v4/dependencies/rhcos/4.4/latest/sha256sum.txt + install_method: netinstall + + hosts_defaults: + network: + name: VM Network + mask: 255.255.255.0 + gw: 192.168.0.1 + dns: + - 192.168.0.2 + - 192.168.1.2 + - 192.168.1.3 + generic: + memory_mb: 16384 + num_cpus: 4 + num_cpu_cores_per_socket: 1 + mem_limit: 16384 + mem_reservation: 0 + disk: 120 + memory_reservation_lock: False + guest_id: other4xLinux64Guest + ignition: none + nested_virt: True + master: + memory_mb: 16384 + num_cpus: 4 + num_cpu_cores_per_socket: 1 + mem_limit: 16384 + mem_reservation: 0 + disk: 120 + memory_reservation_lock: False + guest_id: coreos64Guest + ignition: master.ign + nested_virt: True + + bootstrap: + memory_mb: 16384 + num_cpus: 4 + num_cpu_cores_per_socket: 1 + mem_limit: 16384 + mem_reservation: 0 + disk: 120 + memory_reservation_lock: False + guest_id: coreos64Guest + ignition: bootstrap.ign + nested_virt: True + + worker: + memory_mb: 8192 + num_cpus: 4 + num_cpu_cores_per_socket: 1 + mem_limit: 8192 + mem_reservation: 0 + disk: 120 + memory_reservation_lock: False + guest_id: coreos64Guest + ignition: worker.ign + nested_virt: True + + + + vm_hosts: + - hostname: bootstrap.ocp.mydomain.local + annotation: bootstrap + type: bootstrap + network: + ip: 192.168.0.187 + - hostname: master1.ocp.mydomain.local + type: master + network: + ip: 192.168.0.180 + - hostname: master2.ocp.mydomain.local + type: master + network: + ip: 192.168.0.181 + - hostname: master3.ocp.mydomain.local + type: master + network: + ip: 192.168.0.182 + - hostname: worker1.ocp.mydomain.local + type: worker + network: + ip: 192.168.0.183 + + + \ No newline at end of file diff --git a/docs/examples/inventory/inventory-rhcos-template.yml b/docs/examples/inventory/inventory-rhcos-template.yml new file mode 100644 index 0000000..17e42c2 --- /dev/null +++ b/docs/examples/inventory/inventory-rhcos-template.yml @@ -0,0 +1,115 @@ +# ansible-configured +--- + # defaults file for ocp_vm + haproxy: + hosts: + bastion.ocp.mydomain.local + all: + vars: + + enable_reservation: False # Don't want to reserve CPU for now + cpu_biggest: 2100 # 2.1GHZ + + vcenter: + host: vcenter.mydomain.local + user: administrator@vsphere.local + password: 'FILLME' + datacenter: Datacenter01 + folder: OCP + validate_certs: no + datastore: "DATASTORE" + + ocp_installer: + basedomain: mydomain.local + clustername: ocp + pullsecret: 'FILLME' + sshkey: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}" + install_type: rhcos # fedoracos | rhcos + clients: https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz + installer: https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-install-linux.tar.gz + install_method: template + template: "rhcos-4.4.3-x86_64-vmware.x86_64" + + hosts_defaults: + network: + name: VM Network + mask: 255.255.255.0 + gw: 192.168.0.1 + dns: + - 192.168.0.2 + - 192.168.1.2 + - 192.168.1.3 + generic: + memory_mb: 16384 + num_cpus: 4 + num_cpu_cores_per_socket: 1 + mem_limit: 16384 + mem_reservation: 0 + disk: 120 + memory_reservation_lock: False + guest_id: other4xLinux64Guest + ignition: none + nested_virt: True + master: + memory_mb: 16384 + num_cpus: 4 + num_cpu_cores_per_socket: 1 + mem_limit: 16384 + mem_reservation: 0 + disk: 120 + memory_reservation_lock: False + guest_id: coreos64Guest + ignition: master.ign + nested_virt: True + + bootstrap: + memory_mb: 16384 + num_cpus: 4 + num_cpu_cores_per_socket: 1 + mem_limit: 16384 + mem_reservation: 0 + disk: 120 + memory_reservation_lock: False + guest_id: coreos64Guest + ignition: bootstrap.ign + nested_virt: True + + worker: + memory_mb: 8192 + num_cpus: 4 + num_cpu_cores_per_socket: 1 + mem_limit: 8192 + mem_reservation: 0 + disk: 120 + memory_reservation_lock: False + guest_id: coreos64Guest + ignition: worker.ign + nested_virt: True + + + + vm_hosts: + - hostname: bootstrap.ocp.mydomain.local + annotation: bootstrap + type: bootstrap + network: + ip: 192.168.0.187 + - hostname: master1.ocp.mydomain.local + type: master + network: + ip: 192.168.0.180 + - hostname: master2.ocp.mydomain.local + type: master + network: + ip: 192.168.0.181 + - hostname: master3.ocp.mydomain.local + type: master + network: + ip: 192.168.0.182 + - hostname: worker1.ocp.mydomain.local + type: worker + network: + ip: 192.168.0.183 + + + \ No newline at end of file diff --git a/tasks/41-transpile.yml b/tasks/41-transpile.yml index 766de1c..553aedf 100644 --- a/tasks/41-transpile.yml +++ b/tasks/41-transpile.yml @@ -95,12 +95,4 @@ - set_fact: ign: "{{ ign | combine( { item.hostname: lookup('file', playbook_dir + '/tmp/' + item.hostname + '.ign')| string | b64encode } ) }}" - loop: "{{ vm_hosts }}" - -# - name: Copy Bootstrap in web server -# loop: "{{vm_hosts}}" -# when: -# - "'webserver' in group_names" -# copy: -# src: "{{playbook_dir}}/tmp/{{item.hostname}}.ign" -# dest: "/usr/share/nginx/html/{{item.hostname}}.ign" + loop: "{{ vm_hosts }}" \ No newline at end of file diff --git a/tasks/90-debugmsg.yml b/tasks/90-debugmsg.yml deleted file mode 100644 index 23874f9..0000000 --- a/tasks/90-debugmsg.yml +++ /dev/null @@ -1,4 +0,0 @@ -- name: To connect export this variables - debug: - msg: - - "{{lookup('file', 'README.txt')}}" \ No newline at end of file