From c38f8537904c8d2d3de5a2c2adcf4c4430b78c81 Mon Sep 17 00:00:00 2001 From: Vladimir Protsenko Date: Wed, 2 Nov 2022 20:49:24 +0400 Subject: [PATCH] Fixes for ansible tasks. --- module2/08_ansible/tasks.md | 75 +++++++++++++------------------------ 1 file changed, 25 insertions(+), 50 deletions(-) diff --git a/module2/08_ansible/tasks.md b/module2/08_ansible/tasks.md index f3816f1..cfc03d4 100644 --- a/module2/08_ansible/tasks.md +++ b/module2/08_ansible/tasks.md @@ -310,65 +310,44 @@ $ ansible-playbook 3.yml $ ansible-playbook 4.yml ``` -### 2.6 Проверка установленной версии -Напишем конфигурацию, которая подтверждает, что всё установлено верно. - -```yaml ---- -- hosts: cluster - vars: - - version: "6.22.1" - - greenplum_admin_user: "gpadmin" - become: yes - become_user: {{ greenplum_admin_user }} - tasks: - - name: find installed greenplum version - shell: postgres --gp-version - register: postgres_gp_version - - name: fail if the correct greenplum version is not installed - fail: - msg: "Expected greenplum version {{ version }}, but found '{{ postgres_gp_version.stdout }}'" - when: "version is not defined or version not in postgres_gp_version.stdout" -``` -``` -$ ansible-playbook 5.yml -``` - -### 2.7 Финальная версия +### 2.6 Финальная версия Соберите все предыдущие конфигурации в один файл и запустите ещё раз. Ошибок быть не должно, кластер перешёл в состояние с установленной Greenplum. ```yaml --- -- hosts: all +- hosts: cluster vars: - - version: "6.0.0" + - version: "6.22.1" - greenplum_admin_user: "gpadmin" - greenplum_admin_password: "changeme" - # - package_path: passed via the command line with: -e package_path=./greenplum-db-6.0.0-rhel7-x86_64.rpm - remote_user: root become: yes - become_method: sudo - connection: ssh - gather_facts: yes tasks: - name: create greenplum admin user user: name: "{{ greenplum_admin_user }}" - password: "{{ greenplum_admin_password | password_hash('sha512', 'DvkPtCtNH+UdbePZfm9muQ9pU') }}" - - name: copy package to host - copy: - src: "{{ package_path }}" - dest: /tmp - - - name: cleanup package file from host - file: - path: "/tmp/{{ package_path | basename }}" - state: absent + password: "{{ greenplum_admin_password | password_hash('sha512', 'DvkPtCuQ9pU') }}" + shell: /bin/bash + - name: install software-properties-common + apt: + name: software-properties-common + state: present + - name: install gnupg2 + apt: + name: gnupg2 + state: present + - name: install ppa:greenplum/db + apt_repository: + repo: ppa:greenplum/db + state: present + - name: install package + apt: + name: greenplum-db-6 + state: present - name: find install directory find: - paths: /usr/local + paths: /opt patterns: 'greenplum*' file_type: directory register: installed_dir @@ -379,6 +358,9 @@ $ ansible-playbook 5.yml group: "{{ greenplum_admin_user }}" recurse: yes with_items: "{{ installed_dir.files }}" + - name: add bin folder to gpadmin PATH + shell: echo "PATH={{ item.path }}/bin/:$PATH" >> /home/{{ greenplum_admin_user }}/.bashrc + with_items: "{{ installed_dir.files }}" - name: update pam_limits pam_limits: domain: "{{ greenplum_admin_user }}" @@ -388,13 +370,6 @@ $ ansible-playbook 5.yml with_dict: nofile: 524288 nproc: 131072 - - name: find installed greenplum version - shell: . /usr/local/greenplum-db/greenplum_path.sh && /usr/local/greenplum-db/bin/postgres --gp-version - register: postgres_gp_version - - name: fail if the correct greenplum version is not installed - fail: - msg: "Expected greenplum version {{ version }}, but found '{{ postgres_gp_version.stdout }}'" - when: "version is not defined or version not in postgres_gp_version.stdout" ``` ``` $ ansible-playbook main.yml