Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Config Management/Ansible Auto-Deploy/3node cluster/hosts.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[tigergraph_servers]
server1 ansible_host=hostname ansible_user=graphsql ansible_ssh_private_key_file=/Users/samuel.skidmore/Desktop/qebot.pem
server2 ansible_host=hostname ansible_user=graphsql ansible_ssh_private_key_file=/Users/samuel.skidmore/Desktop/qebot.pem
server3 ansible_host=hostname ansible_user=graphsql ansible_ssh_private_key_file=/Users/samuel.skidmore/Desktop/qebot.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"BasicConfig": {
"TigerGraph": {
"Username": "tigergraph",
"[comment]":"Provide password for tigergraph user, if the user already exists, we won't change the password. If the password is empty, we will set it to default value 'tigergraph'.",
"[comment]": "TigerGraph does not support passwords with special characters such as '$'. Please change your password if it contains such special characters.",
"Password": "tigergraph",
"SSHPort": 22,
"[comment]":"(Optional)Provide valid private key file below to replace tigergraph.rsa and tigergraph.pub, which will be generated by default.",
"PrivateKeyFile": "",
"PublicKeyFile": ""
},
"RootDir": {
"AppRoot": "/home/tigergraph/tigergraph/app",
"DataRoot": "/home/tigergraph/tigergraph/data",
"LogRoot": "/home/tigergraph/tigergraph/log",
"TempRoot": "/home/tigergraph/tigergraph/tmp"
},
"License": "",
"[comment]":"You can add more nodes by string 'node_id: IP', appending to the following json array. Otherwise, it installs single node locally by default.",
"NodeList": [
"m1: hostname", "m2: hostname", "m3: hostname"
]
},
"AdvancedConfig": {
"[comment]": "Keep the default ClusterConfig if installing locally",
"ClusterConfig": {
"[comment]": "All nodes must have the same login configurations",
"LoginConfig": {
"SudoUser": "graphsql",
"[comment]": "choose login method: 'P' for SSH using password or 'K' for SSH using key file (e.g. ec2_key.pem)",
"[comment]": "TigerGraph does not support passwords with special characters such as '$'. Please change your password if it contains such special characters.",
"Method": "K",
"P": "sudoUserPassword",
"K": "/home/graphsql/qebot.pem"
},
"[comment]": "To install a high-availability cluster, please specify the ReplicationFactor greater than 1",
"ReplicationFactor": 3
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
- hosts: tigergraph_servers
become: yes
tasks:
- name: Update and upgrade apt packages
become: yes
apt:
update_cache: yes
upgrade: yes
when: ansible_os_family == "Debian"

- name: Install prerequisites for CentOS/RedHat
yum:
name:
- tar
- curl
- cronie
- iproute
- util-linux-ng
- net-tools
- nc
- coreutils
- openssh-clients
- openssh-server
- sshpass
state: present
when: ansible_os_family == "RedHat"

- name: Install prerequisites for Ubuntu/Debian
apt:
name:
- tar
- curl
- cron
- iproute2
- util-linux
- net-tools
- netcat
- coreutils
- openssh-client
- openssh-server
- sshpass
state: present
when: ansible_os_family == "Debian"

- name: Install basic applications
apt:
name: "{{ item }}"
state: present
loop:
- vim
- htop
- nano
- git
when: ansible_os_family == "Debian"

- name: Install basic applications
yum:
name: "{{ item }}"
state: present
loop:
- vim-enhanced
- htop
- nano
- git
when: ansible_os_family == "RedHat"

- name: Download TigerGraph installer
get_url:
url: "https://tigergraph-release-download.s3.us-west-1.amazonaws.com/enterprise-edition/prebuild/tigergraph-4.1.0-offline-07180247.tar.gz?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAWNM34YTI5OWLYSEX%2F20240816%2Fus-west-1%2Fs3%2Faws4_request&X-Amz-Date=20240816T173132Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=9c7aaeeafd938e9401d6a2e0214dd1edea694c199a007ac3a5d91bba89c48d28"
dest: /home/graphsql/tigergraphansible.tar.gz
mode: '0440'
when: inventory_hostname == groups['tigergraph_servers'][0]

- name: Extract TigerGraph installer
unarchive:
src: /home/graphsql/tigergraphansible.tar.gz
dest: /home/graphsql/
remote_src: yes
when: inventory_hostname == groups['tigergraph_servers'][0]

- name: Find TigerGraph installation directory
find:
paths: "/home/graphsql"
file_type: directory
patterns: "tigergraph-*"
register: tg_dir
when: inventory_hostname == groups['tigergraph_servers'][0]

- name: Copy custom install_conf.json to TigerGraph installation directory
copy:
src: ./install_conf.json
dest: "{{ tg_dir.files[0].path }}/install_conf.json"
when: inventory_hostname == groups['tigergraph_servers'][0]


- name: Run TigerGraph installer non-interactively
shell: |
cd {{ tg_dir.files[0].path }}
sudo ./install.sh -n
args:
creates: "{{ tg_dir.files[0].path }}/tgdb/conf/tgdb.conf"
when: ansible_play_hosts[0] == inventory_hostname

- name: Cleanup installation files
file:
path: "{{ item }}"
state: absent
loop:
- /home/graphsql/tigergraphansible.tar.gz
- "{{ tg_dir.files[0].path }}"
when: ansible_play_hosts[0] == inventory_hostname
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
- name: Transfer GSQL file to server
copy:
src: "{{ gsql_file }}"
dest: "/tmp/{{ gsql_file | basename }}"

- name: Run GSQL script
become: yes
become_user: tigergraph
shell: |
gsql /tmp/{{ gsql_file | basename }}
register: gsql_output

- name: Output GSQL script execution result
debug:
msg: "{{ gsql_output.stdout }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tigergraph_servers]
server1 ansible_host=hostname ansible_user=graphsql ansible_ssh_private_key_file=/Users/samuel.skidmore/Desktop/qebot.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
- name: Transfer data file to server
copy:
src: "{{ csv_file }}"
dest: "/home/tigergraph/tmp/{{ csv_file | basename }}"

- name: Load data into TigerGraph
become: yes
become_user: tigergraph
shell: |
gsql -g social_net 'RUN LOADING JOB load_job_name USING file_path="/home/tigergraph/tmp/{{ csv_file | basename }}"'
register: load_result

- name: Output load result
debug:
msg: "{{ load_result.stdout }}"

- name: Confirm data load
debug:
msg: "Data loaded successfully for {{ csv_file | basename }}"
when: "'Successfully' in load_result.stdout"
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- hosts: tigergraph_servers
become: true
become_user: tigergraph
become_method: sudo
tasks:
- name: Setup TigerGraph
include_tasks: setup_tigergraph.yml

- name: Execute each GSQL script
include_tasks: execute_gsql.yml
loop: "{{ lookup('fileglob', 'gsql_scripts/*.gsql', wantlist=true) }}"
loop_control:
loop_var: gsql_file

- name: Load data from each CSV file
include_tasks: load_data.yml
loop: "{{ lookup('fileglob', 'data_files/*.csv', wantlist=true) }}"
loop_control:
loop_var: csv_file
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
tasks:
- name: Ensure TigerGraph is running
become: true
become_user: tigergraph
become_method: sudo
shell: gadmin status -v
ignore_errors: true

- name: Check TigerGraph status
become: true
become_user: tigergraph
become_method: sudo
shell: gadmin status
register: tg_status

- name: Output status
debug:
msg: "{{ tg_status.stdout }}"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[defaults]
inventory = ./inventory.ini
host_key_checking = False
remote_tmp = /home/tigergraph/tigergraph/ansible-tmp
pipelining = True
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
enable_configs:
- name: GSQL.UDF.EnablePutExpr
value: "true"
- name: RESTPP.Factory.EnableAuth
value: "false"
- name: GSQL.UDF.EnablePutTgExpr
value: "true"
- name: GSQL.UDF.EnablePutTokenBank
value: "true"
- name: GSQL.UDF.Policy.Enable
value: "false"




Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
other_configs:
- name: Admin.BasicConfig.LogConfig.LogFileMaxDurationDay
value: 50
- name: Admin.BasicConfig.LogConfig.LogFileMaxSizeMB
value: 100
- name: RESTPP.Factory.DefaultQueryTimeoutSec
value: 50000
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tigergraph]
server1 ansible_host=IPofHost ansible_user=graphsql ansible_ssh_private_key_file=.pemkey
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
- name: Configure TigerGraph
hosts: tigergraph
become: yes
become_user: tigergraph
vars_files:
- configs/enable_configs.yml
- configs/other_configs.yml

tasks:
- name: Debug PATH
shell: echo $PATH
register: path_output

- debug:
var: path_output.stdout

- name: Check and set enable configurations
shell: |
export PATH=$PATH:/home/tigergraph/tigergraph/app/cmd
current_value=$(gadmin config get {{ item.name }})
if [ "$current_value" != "{{ item.value }}" ]; then
gadmin config set {{ item.name }} {{ item.value }}
echo 'changed'
else
echo 'no change'
fi
with_items: "{{ enable_configs }}"
register: set_enable_configs
changed_when: "'changed' in set_enable_configs.stdout_lines"

- name: Check and set other configurations
shell: |
export PATH=$PATH:/home/tigergraph/tigergraph/app/cmd
current_value=$(gadmin config get {{ item.name }})
if [ "$current_value" != "{{ item.value }}" ]; then
gadmin config set {{ item.name }} {{ item.value }}
echo 'changed'
else
echo 'no change'
fi
with_items: "{{ other_configs }}"
register: set_other_configs
changed_when: "'changed' in set_other_configs.stdout_lines"

- name: Apply configuration changes if needed
shell: |
export PATH=$PATH:/home/tigergraph/tigergraph/app/cmd
echo 'y' | gadmin config apply
when: set_enable_configs.changed or set_other_configs.changed
register: apply_configs

- name: Restart services if configuration was applied
shell: |
export PATH=$PATH:/home/tigergraph/tigergraph/app/cmd
gadmin restart all -y
when: apply_configs.changed
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
TigerGraph Configuration Management
This project utilizes Ansible to automate the configuration management of TigerGraph instances.

Table of Contents
Overview
Requirements
Installation
Usage
Configuration
Tasks
License
Overview
This project configures various settings for TigerGraph using Ansible playbooks. It aims to ensure that the desired configurations are applied consistently across multiple TigerGraph instances.

Requirements
Ansible (version 2.10 or higher)
SSH access to the TigerGraph server
Appropriate user privileges
Installation

Install Ansible:


pip install ansible
Usage
Run the Ansible playbook to apply configurations:


ansible-playbook -i inventory.ini playbook.yml

To run Ansible in check mode, you can use the --check flag when running a playbook. Here's an example command:

ansible-playbook playbook.yml --check
This command will run the specified playbook in check mode, showing you what changes would occur without actually applying them.

Additionally, if you want to see the detailed differences of what would be changed, you can combine --check with the --diff flag:


ansible-playbook playbook.yml --check --diff
This will show the differences between the current state and the state that would be achieved by running the playbook, which is especially useful for configuration management tasks.





Configuration
The configurations are defined in YAML files located in the configs directory:

enable_configs.yml: Contains settings that are to be enabled.
other_configs.yml: Contains additional configurations.
Tasks
The playbook performs the following tasks:

Debug the current PATH environment variable.
Check and set enable configurations.
Check and set other configurations.
Apply configuration changes if needed.
Restart services if configurations were applied.


05b6a289-1740-4520-aff2-316e16cc3995
Loading