A sample Ansible playbook to install a Greenplum Database software release onto the hosts that will comprise a Greenplum Database system.

This Ansible playbook shows how tasks described in Installing the Greenplum Database Software might be automated using Ansible.

Important

This playbook is provided as an example only to illustrate how Greenplum Database cluster configuration and software installation tasks can be automated using provisioning tools such as Ansible, Chef, or Puppet. VMware does not provide support for Ansible or for the playbook presented in this example.

The example playbook is designed for use with CentOS 7. It creates the gpadmin user, installs the Greenplum Database software release, sets the owner and group of the installed software to gpadmin, and sets the Pam security limits for the gpadmin user.

You can revise the script to work with your operating system platform and to perform additional host configuration tasks.

Following are steps to use this Ansible playbook.

  1. Install Ansible on the control node using your package manager. See the Ansible documentation for help with installation.
  2. Set up passwordless SSH from the control node to all hosts that will be a part of the Greenplum Database cluster. You can use the ssh-copy-id command to install your public SSH key on each host in the cluster. Alternatively, your provisioning software may provide more convenient ways to securely install public keys on multiple hosts.
  3. Create an Ansible inventory by creating a file called hosts with a list of the hosts that will comprise your Greenplum Database cluster. For example:

    1. mdw
    2. sdw1
    3. sdw2
    4. ...

    This file can be edited and used with the Greenplum Database gpssh-exkeys and gpinitsystem utilities later on.

  4. Copy the playbook code below to a file ansible-playbook.yml on your Ansible control node.

  5. Edit the playbook variables at the top of the playbook, such as the gpadmin administrative user and password to create, and the version of Greenplum Database you are installing.

  6. Run the playbook, passing the package to be installed to the package_path parameter.

    1. ansible-playbook ansible-playbook.yml -i hosts -e package_path=./greenplum-db-6.0.0-rhel7-x86_64.rpm

Ansible Playbook - Greenplum Database Installation for CentOS 7

  1. ---
  2. - hosts: all
  3. vars:
  4. - version: "6.0.0"
  5. - greenplum_admin_user: "gpadmin"
  6. - greenplum_admin_password: "changeme"
  7. # - package_path: passed via the command line with: -e package_path=./greenplum-db-6.0.0-rhel7-x86_64.rpm
  8. remote_user: root
  9. become: yes
  10. become_method: sudo
  11. connection: ssh
  12. gather_facts: yes
  13. tasks:
  14. - name: create greenplum admin user
  15. user:
  16. name: "{{ greenplum_admin_user }}"
  17. password: "{{ greenplum_admin_password | password_hash('sha512', 'DvkPtCtNH+UdbePZfm9muQ9pU') }}"
  18. - name: copy package to host
  19. copy:
  20. src: "{{ package_path }}"
  21. dest: /tmp
  22. - name: install package
  23. yum:
  24. name: "/tmp/{{ package_path | basename }}"
  25. state: present
  26. - name: cleanup package file from host
  27. file:
  28. path: "/tmp/{{ package_path | basename }}"
  29. state: absent
  30. - name: find install directory
  31. find:
  32. paths: /usr/local
  33. patterns: 'greenplum*'
  34. file_type: directory
  35. register: installed_dir
  36. - name: change install directory ownership
  37. file:
  38. path: '{{ item.path }}'
  39. owner: "{{ greenplum_admin_user }}"
  40. group: "{{ greenplum_admin_user }}"
  41. recurse: yes
  42. with_items: "{{ installed_dir.files }}"
  43. - name: update pam_limits
  44. pam_limits:
  45. domain: "{{ greenplum_admin_user }}"
  46. limit_type: '-'
  47. limit_item: "{{ item.key }}"
  48. value: "{{ item.value }}"
  49. with_dict:
  50. nofile: 524288
  51. nproc: 131072
  52. - name: find installed greenplum version
  53. shell: . /usr/local/greenplum-db/greenplum_path.sh && /usr/local/greenplum-db/bin/postgres --gp-version
  54. register: postgres_gp_version
  55. - name: fail if the correct greenplum version is not installed
  56. fail:
  57. msg: "Expected greenplum version {{ version }}, but found '{{ postgres_gp_version.stdout }}'"
  58. when: "version is not defined or version not in postgres_gp_version.stdout"

When the playbook has run successfully, you can proceed with Creating the Data Storage Areas and Initializing a Greenplum Database System.

Parent topic: Installing and Upgrading Greenplum