Fixes for ansible tasks.

pull/1/head
Vladimir Protsenko 2 years ago
parent d8f6d05d45
commit c38f853790

@ -310,65 +310,44 @@ $ ansible-playbook 3.yml
$ ansible-playbook 4.yml $ ansible-playbook 4.yml
``` ```
### 2.6 Проверка установленной версии
Напишем конфигурацию, которая подтверждает, что всё установлено верно. ### 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 Финальная версия
Соберите все предыдущие конфигурации в один файл и запустите ещё раз. Ошибок быть не должно, кластер перешёл в состояние с установленной Greenplum. Соберите все предыдущие конфигурации в один файл и запустите ещё раз. Ошибок быть не должно, кластер перешёл в состояние с установленной Greenplum.
```yaml ```yaml
--- ---
- hosts: all - hosts: cluster
vars: vars:
- version: "6.0.0" - version: "6.22.1"
- greenplum_admin_user: "gpadmin" - greenplum_admin_user: "gpadmin"
- greenplum_admin_password: "changeme" - 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: yes
become_method: sudo
connection: ssh
gather_facts: yes
tasks: tasks:
- name: create greenplum admin user - name: create greenplum admin user
user: user:
name: "{{ greenplum_admin_user }}" name: "{{ greenplum_admin_user }}"
password: "{{ greenplum_admin_password | password_hash('sha512', 'DvkPtCtNH+UdbePZfm9muQ9pU') }}" password: "{{ greenplum_admin_password | password_hash('sha512', 'DvkPtCuQ9pU') }}"
- name: copy package to host shell: /bin/bash
copy: - name: install software-properties-common
src: "{{ package_path }}" apt:
dest: /tmp name: software-properties-common
state: present
- name: cleanup package file from host - name: install gnupg2
file: apt:
path: "/tmp/{{ package_path | basename }}" name: gnupg2
state: absent 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 - name: find install directory
find: find:
paths: /usr/local paths: /opt
patterns: 'greenplum*' patterns: 'greenplum*'
file_type: directory file_type: directory
register: installed_dir register: installed_dir
@ -379,6 +358,9 @@ $ ansible-playbook 5.yml
group: "{{ greenplum_admin_user }}" group: "{{ greenplum_admin_user }}"
recurse: yes recurse: yes
with_items: "{{ installed_dir.files }}" 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 - name: update pam_limits
pam_limits: pam_limits:
domain: "{{ greenplum_admin_user }}" domain: "{{ greenplum_admin_user }}"
@ -388,13 +370,6 @@ $ ansible-playbook 5.yml
with_dict: with_dict:
nofile: 524288 nofile: 524288
nproc: 131072 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 $ ansible-playbook main.yml

Loading…
Cancel
Save