From 82ef5bc291006b51207b9e32626251a03c776548 Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Mon, 19 Dec 2016 14:47:10 +0100 Subject: Add RPM checks as an adhoc playbook --- playbooks/adhoc/preflight/README.md | 51 ++++++++++++ playbooks/adhoc/preflight/check.yml | 159 ++++++++++++++++++++++++++++++++++++ playbooks/adhoc/preflight/library | 1 + 3 files changed, 211 insertions(+) create mode 100644 playbooks/adhoc/preflight/README.md create mode 100644 playbooks/adhoc/preflight/check.yml create mode 120000 playbooks/adhoc/preflight/library (limited to 'playbooks') diff --git a/playbooks/adhoc/preflight/README.md b/playbooks/adhoc/preflight/README.md new file mode 100644 index 000000000..871c6af01 --- /dev/null +++ b/playbooks/adhoc/preflight/README.md @@ -0,0 +1,51 @@ +# Preflight checks + +Here we provide an Ansible playbook for detecting potential roadblocks prior to +an install or upgrade. + +Ansible's default operation mode is to fail fast, on the first error. However, +when performing checks, it is useful to gather as much information about +problems as possible in a single run. + +The `check.yml` playbook runs a battery of checks against the inventory hosts +and tells Ansible to ignore intermediate errors, thus giving a more complete +diagnostic of the state of each host. Still, if any check failed, the playbook +run will be marked as having failed. + +To facilitate understanding the problems that were encountered, we provide a +custom callback plugin to summarize execution errors at the end of a playbook +run. + +--- + +*Note that currently the `check.yml` playbook is only useful for RPM-based +installations. Containerized installs are excluded from checks for now, but +might be included in the future if there is demand for that.* + +--- + +## Running + +With an installation of Ansible 2.2 or greater, run the playbook directly +against your inventory file. Here is the step-by-step: + +1. If you haven't done it yet, clone this repository: + + ```console + $ git clone https://github.com/openshift/openshift-ansible + $ cd openshift-ansible + ``` + +2. Configure a custom callback plugin to get a summary of problems at the end of +the playbook run: + + ```console + $ export ANSIBLE_CALLBACK_PLUGINS=callback_plugins \ + ANSIBLE_STDOUT_CALLBACK=default_plus_summary + ``` + +3. Run the playbook: + + ```console + $ ansible-playbook -i playbooks/adhoc/preflight/check.yml + ``` diff --git a/playbooks/adhoc/preflight/check.yml b/playbooks/adhoc/preflight/check.yml new file mode 100644 index 000000000..b66c1a824 --- /dev/null +++ b/playbooks/adhoc/preflight/check.yml @@ -0,0 +1,159 @@ +--- +- hosts: OSEv3 + gather_facts: no + tasks: + - set_fact: + deployment_type: "{{ deployment_type | default('openshift-enterprise') }}" + containerized: "{{ containerized | default('no') | bool }}" + openshift_release: "{{ openshift_release | default('3.3') }}" + oo_preflight_check_results: "{{ oo_preflight_check_results | default([]) }}" + +- hosts: OSEv3 + name: check content available on all hosts + gather_facts: no + ignore_errors: yes + tasks: + - when: + - not containerized + block: + + - name: determine if yum update will work + action: check_yum_update + register: r + + - set_fact: + oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'check content available on all hosts'})] }}" + + - name: determine if expected version matches what is available + aos_version: + version: "{{ openshift_release }}" + when: + - deployment_type == "openshift-enterprise" + register: r + + - set_fact: + oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'determine if expected version matches what is available'})] }}" + +- hosts: masters + name: determine if yum install of master pkgs will work + gather_facts: no + ignore_errors: yes + tasks: + - when: + - not containerized + block: + + - name: main packages for enterprise + when: + - deployment_type == "openshift-enterprise" + check_yum_update: + packages: + - atomic-openshift + - atomic-openshift-clients + - atomic-openshift-master + register: r + + - set_fact: + oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'main packages for enterprise'})] }}" + + - name: main packages for origin + when: + - deployment_type == "origin" + check_yum_update: + packages: + - origin + - origin-clients + - origin-master + register: r + + - set_fact: + oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'main packages for origin'})] }}" + + - name: other master packages + check_yum_update: + packages: + - etcd + - bash-completion + - cockpit-bridge + - cockpit-docker + - cockpit-kubernetes + - cockpit-shell + - cockpit-ws + - httpd-tools + register: r + + - set_fact: + oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'other master packages'})] }}" + +- hosts: nodes + name: determine if yum install of node pkgs will work + gather_facts: no + ignore_errors: yes + tasks: + - when: + - not containerized + block: + + - name: main packages for enterprise + when: + - deployment_type == "openshift-enterprise" + check_yum_update: + packages: + - atomic-openshift + - atomic-openshift-node + - atomic-openshift-sdn-ovs + register: r + + - set_fact: + oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'main packages for enterprise'})] }}" + + - name: main packages for origin + when: + - deployment_type == "origin" + check_yum_update: + packages: + - origin + - origin-node + - origin-sdn-ovs + register: r + + - set_fact: + oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'main packages for origin'})] }}" + + - name: other node packages + check_yum_update: + packages: + - docker + - PyYAML + - firewalld + - iptables + - iptables-services + - nfs-utils + - ntp + - yum-utils + - dnsmasq + - libselinux-python + - ceph-common + - glusterfs-fuse + - iscsi-initiator-utils + - pyparted + - python-httplib2 + - openssl + - flannel + - bind + register: r + + - set_fact: + oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'other node packages'})] }}" + +- hosts: OSEv3 + name: verify check results + gather_facts: no + tasks: + + - set_fact: + oo_preflight_check_failures: "{{ oo_preflight_check_results | select('failed', 'equalto', True) | list }}" + + - name: ensure all checks succeed + action: fail + when: oo_preflight_check_failures diff --git a/playbooks/adhoc/preflight/library b/playbooks/adhoc/preflight/library new file mode 120000 index 000000000..ba40d2f56 --- /dev/null +++ b/playbooks/adhoc/preflight/library @@ -0,0 +1 @@ +../../../library \ No newline at end of file -- cgit v1.2.3 From 9041a816210132b1dad86217ecfef5f9fec4a8d2 Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Fri, 6 Jan 2017 20:53:05 +0100 Subject: Refactor preflight check into roles --- playbooks/adhoc/preflight/README.md | 10 +-- playbooks/adhoc/preflight/check.yml | 153 +++--------------------------------- playbooks/adhoc/preflight/library | 1 - 3 files changed, 14 insertions(+), 150 deletions(-) delete mode 120000 playbooks/adhoc/preflight/library (limited to 'playbooks') diff --git a/playbooks/adhoc/preflight/README.md b/playbooks/adhoc/preflight/README.md index 871c6af01..7636ecca3 100644 --- a/playbooks/adhoc/preflight/README.md +++ b/playbooks/adhoc/preflight/README.md @@ -36,15 +36,7 @@ against your inventory file. Here is the step-by-step: $ cd openshift-ansible ``` -2. Configure a custom callback plugin to get a summary of problems at the end of -the playbook run: - - ```console - $ export ANSIBLE_CALLBACK_PLUGINS=callback_plugins \ - ANSIBLE_STDOUT_CALLBACK=default_plus_summary - ``` - -3. Run the playbook: +2. Run the playbook: ```console $ ansible-playbook -i playbooks/adhoc/preflight/check.yml diff --git a/playbooks/adhoc/preflight/check.yml b/playbooks/adhoc/preflight/check.yml index b66c1a824..460ba4ce4 100644 --- a/playbooks/adhoc/preflight/check.yml +++ b/playbooks/adhoc/preflight/check.yml @@ -1,159 +1,32 @@ --- - hosts: OSEv3 gather_facts: no - tasks: - - set_fact: - deployment_type: "{{ deployment_type | default('openshift-enterprise') }}" - containerized: "{{ containerized | default('no') | bool }}" - openshift_release: "{{ openshift_release | default('3.3') }}" - oo_preflight_check_results: "{{ oo_preflight_check_results | default([]) }}" + roles: + - openshift_preflight/facts - hosts: OSEv3 - name: check content available on all hosts + name: checks that apply to all hosts gather_facts: no ignore_errors: yes - tasks: - - when: - - not containerized - block: - - - name: determine if yum update will work - action: check_yum_update - register: r - - - set_fact: - oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'check content available on all hosts'})] }}" - - - name: determine if expected version matches what is available - aos_version: - version: "{{ openshift_release }}" - when: - - deployment_type == "openshift-enterprise" - register: r - - - set_fact: - oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'determine if expected version matches what is available'})] }}" + roles: + - openshift_preflight/common - hosts: masters - name: determine if yum install of master pkgs will work + name: checks that apply to masters gather_facts: no ignore_errors: yes - tasks: - - when: - - not containerized - block: - - - name: main packages for enterprise - when: - - deployment_type == "openshift-enterprise" - check_yum_update: - packages: - - atomic-openshift - - atomic-openshift-clients - - atomic-openshift-master - register: r - - - set_fact: - oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'main packages for enterprise'})] }}" - - - name: main packages for origin - when: - - deployment_type == "origin" - check_yum_update: - packages: - - origin - - origin-clients - - origin-master - register: r - - - set_fact: - oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'main packages for origin'})] }}" - - - name: other master packages - check_yum_update: - packages: - - etcd - - bash-completion - - cockpit-bridge - - cockpit-docker - - cockpit-kubernetes - - cockpit-shell - - cockpit-ws - - httpd-tools - register: r - - - set_fact: - oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'other master packages'})] }}" + roles: + - openshift_preflight/masters - hosts: nodes - name: determine if yum install of node pkgs will work + name: checks that apply to nodes gather_facts: no ignore_errors: yes - tasks: - - when: - - not containerized - block: - - - name: main packages for enterprise - when: - - deployment_type == "openshift-enterprise" - check_yum_update: - packages: - - atomic-openshift - - atomic-openshift-node - - atomic-openshift-sdn-ovs - register: r - - - set_fact: - oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'main packages for enterprise'})] }}" - - - name: main packages for origin - when: - - deployment_type == "origin" - check_yum_update: - packages: - - origin - - origin-node - - origin-sdn-ovs - register: r - - - set_fact: - oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'main packages for origin'})] }}" - - - name: other node packages - check_yum_update: - packages: - - docker - - PyYAML - - firewalld - - iptables - - iptables-services - - nfs-utils - - ntp - - yum-utils - - dnsmasq - - libselinux-python - - ceph-common - - glusterfs-fuse - - iscsi-initiator-utils - - pyparted - - python-httplib2 - - openssl - - flannel - - bind - register: r - - - set_fact: - oo_preflight_check_results: "{{ oo_preflight_check_results + [r|combine({'_task': 'other node packages'})] }}" + roles: + - openshift_preflight/nodes - hosts: OSEv3 name: verify check results gather_facts: no - tasks: - - - set_fact: - oo_preflight_check_failures: "{{ oo_preflight_check_results | select('failed', 'equalto', True) | list }}" - - - name: ensure all checks succeed - action: fail - when: oo_preflight_check_failures + roles: + - openshift_preflight/verify_status diff --git a/playbooks/adhoc/preflight/library b/playbooks/adhoc/preflight/library deleted file mode 120000 index ba40d2f56..000000000 --- a/playbooks/adhoc/preflight/library +++ /dev/null @@ -1 +0,0 @@ -../../../library \ No newline at end of file -- cgit v1.2.3 From 22d60dcccf62abd52caf9233fdcf0835d6343681 Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Thu, 12 Jan 2017 17:07:04 +0100 Subject: Move playbook to BYO Because that's the main playbook directory in use. --- playbooks/adhoc/preflight/README.md | 43 ----------------------------- playbooks/adhoc/preflight/check.yml | 32 --------------------- playbooks/byo/openshift-preflight/README.md | 43 +++++++++++++++++++++++++++++ playbooks/byo/openshift-preflight/check.yml | 32 +++++++++++++++++++++ 4 files changed, 75 insertions(+), 75 deletions(-) delete mode 100644 playbooks/adhoc/preflight/README.md delete mode 100644 playbooks/adhoc/preflight/check.yml create mode 100644 playbooks/byo/openshift-preflight/README.md create mode 100644 playbooks/byo/openshift-preflight/check.yml (limited to 'playbooks') diff --git a/playbooks/adhoc/preflight/README.md b/playbooks/adhoc/preflight/README.md deleted file mode 100644 index 7636ecca3..000000000 --- a/playbooks/adhoc/preflight/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# Preflight checks - -Here we provide an Ansible playbook for detecting potential roadblocks prior to -an install or upgrade. - -Ansible's default operation mode is to fail fast, on the first error. However, -when performing checks, it is useful to gather as much information about -problems as possible in a single run. - -The `check.yml` playbook runs a battery of checks against the inventory hosts -and tells Ansible to ignore intermediate errors, thus giving a more complete -diagnostic of the state of each host. Still, if any check failed, the playbook -run will be marked as having failed. - -To facilitate understanding the problems that were encountered, we provide a -custom callback plugin to summarize execution errors at the end of a playbook -run. - ---- - -*Note that currently the `check.yml` playbook is only useful for RPM-based -installations. Containerized installs are excluded from checks for now, but -might be included in the future if there is demand for that.* - ---- - -## Running - -With an installation of Ansible 2.2 or greater, run the playbook directly -against your inventory file. Here is the step-by-step: - -1. If you haven't done it yet, clone this repository: - - ```console - $ git clone https://github.com/openshift/openshift-ansible - $ cd openshift-ansible - ``` - -2. Run the playbook: - - ```console - $ ansible-playbook -i playbooks/adhoc/preflight/check.yml - ``` diff --git a/playbooks/adhoc/preflight/check.yml b/playbooks/adhoc/preflight/check.yml deleted file mode 100644 index 460ba4ce4..000000000 --- a/playbooks/adhoc/preflight/check.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -- hosts: OSEv3 - gather_facts: no - roles: - - openshift_preflight/facts - -- hosts: OSEv3 - name: checks that apply to all hosts - gather_facts: no - ignore_errors: yes - roles: - - openshift_preflight/common - -- hosts: masters - name: checks that apply to masters - gather_facts: no - ignore_errors: yes - roles: - - openshift_preflight/masters - -- hosts: nodes - name: checks that apply to nodes - gather_facts: no - ignore_errors: yes - roles: - - openshift_preflight/nodes - -- hosts: OSEv3 - name: verify check results - gather_facts: no - roles: - - openshift_preflight/verify_status diff --git a/playbooks/byo/openshift-preflight/README.md b/playbooks/byo/openshift-preflight/README.md new file mode 100644 index 000000000..b50292eac --- /dev/null +++ b/playbooks/byo/openshift-preflight/README.md @@ -0,0 +1,43 @@ +# OpenShift preflight checks + +Here we provide an Ansible playbook for detecting potential roadblocks prior to +an install or upgrade. + +Ansible's default operation mode is to fail fast, on the first error. However, +when performing checks, it is useful to gather as much information about +problems as possible in a single run. + +The `check.yml` playbook runs a battery of checks against the inventory hosts +and tells Ansible to ignore intermediate errors, thus giving a more complete +diagnostic of the state of each host. Still, if any check failed, the playbook +run will be marked as having failed. + +To facilitate understanding the problems that were encountered, we provide a +custom callback plugin to summarize execution errors at the end of a playbook +run. + +--- + +*Note that currently the `check.yml` playbook is only useful for RPM-based +installations. Containerized installs are excluded from checks for now, but +might be included in the future if there is demand for that.* + +--- + +## Running + +With an installation of Ansible 2.2 or greater, run the playbook directly +against your inventory file. Here is the step-by-step: + +1. If you haven't done it yet, clone this repository: + + ```console + $ git clone https://github.com/openshift/openshift-ansible + $ cd openshift-ansible + ``` + +2. Run the playbook: + + ```console + $ ansible-playbook -i playbooks/byo/openshift-preflight/check.yml + ``` diff --git a/playbooks/byo/openshift-preflight/check.yml b/playbooks/byo/openshift-preflight/check.yml new file mode 100644 index 000000000..460ba4ce4 --- /dev/null +++ b/playbooks/byo/openshift-preflight/check.yml @@ -0,0 +1,32 @@ +--- +- hosts: OSEv3 + gather_facts: no + roles: + - openshift_preflight/facts + +- hosts: OSEv3 + name: checks that apply to all hosts + gather_facts: no + ignore_errors: yes + roles: + - openshift_preflight/common + +- hosts: masters + name: checks that apply to masters + gather_facts: no + ignore_errors: yes + roles: + - openshift_preflight/masters + +- hosts: nodes + name: checks that apply to nodes + gather_facts: no + ignore_errors: yes + roles: + - openshift_preflight/nodes + +- hosts: OSEv3 + name: verify check results + gather_facts: no + roles: + - openshift_preflight/verify_status -- cgit v1.2.3 From c4aec0fbd112fd1c8503e935ac954da268a2fdff Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Thu, 12 Jan 2017 18:30:24 +0100 Subject: Replace custom variables with openshift_facts Note: on a simple example run of ansible-playbook against a single docker-based host, I saw the execution time jump from 7s to 17s. That's unfortunate, but it is probably better to reuse openshift_facts, than to come up with new variables. --- playbooks/byo/openshift-preflight/check.yml | 1 - 1 file changed, 1 deletion(-) (limited to 'playbooks') diff --git a/playbooks/byo/openshift-preflight/check.yml b/playbooks/byo/openshift-preflight/check.yml index 460ba4ce4..94f53eb84 100644 --- a/playbooks/byo/openshift-preflight/check.yml +++ b/playbooks/byo/openshift-preflight/check.yml @@ -1,6 +1,5 @@ --- - hosts: OSEv3 - gather_facts: no roles: - openshift_preflight/facts -- cgit v1.2.3 From 01046c33e0bdcaf44dbd9bfcdf84f1a9a335437c Mon Sep 17 00:00:00 2001 From: Rodolfo Carvalho Date: Fri, 13 Jan 2017 17:06:57 +0100 Subject: Rename subrole facts -> init Trying to improve the name, `init` needs to be loaded before calling other subroles. We don't make `init` a dependency of `common`, `masters` and `nodes` to avoid running the relatively slow `openshift_facts` multiple times. --- playbooks/byo/openshift-preflight/check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'playbooks') diff --git a/playbooks/byo/openshift-preflight/check.yml b/playbooks/byo/openshift-preflight/check.yml index 94f53eb84..32673d01d 100644 --- a/playbooks/byo/openshift-preflight/check.yml +++ b/playbooks/byo/openshift-preflight/check.yml @@ -1,7 +1,7 @@ --- - hosts: OSEv3 roles: - - openshift_preflight/facts + - openshift_preflight/init - hosts: OSEv3 name: checks that apply to all hosts -- cgit v1.2.3