Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a3bc527

Browse files
committed
Node addition fixed: specifying proper shardlord connstring.
We really should verify that shardlors's connstring actually belongs to it.
1 parent 2ca5564 commit a3bc527

File tree

6 files changed

+20
-21
lines changed

6 files changed

+20
-21
lines changed

devops/.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
*.retry
2-
inventory/manual
2+
inventory_manual/manual
33
logs/
44

55
/postgresql.conf.common
66
/postgresql.conf.lord
7-
/postgresql.conf.worker
7+
/postgresql.conf.worker
8+
9+
*.log

devops/init.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### initdb and send configs
1+
### initdb, send configs and add all workers.
22

33
---
44
- hosts: nodes
@@ -68,7 +68,7 @@
6868
- name: add manual workers
6969
command: >
7070
psql -p {{ pg_port }} -c "select shardman.add_node(
71-
'hostaddr={{ item]}} port={{ pg_port }}')"
71+
'hostaddr={{ item }} port={{ pg_port }}')"
7272
with_items: "{{ groups.manual_workers }}"
7373
tags:
7474
- add_nodes

devops/inventory

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pg_repo=git://git.postgresql.org/git/postgresql.git
1717
pg_version_tag=REL_10_STABLE
1818
pg_prefix="{{ansible_env.HOME}}/pg"
1919
pg_src="{{pg_prefix}}/src"
20+
cflags="-O0"
2021
pg_dst="{{pg_prefix}}/install"
2122
pg_datadir="{{pg_prefix}}/data_{{pg_port}}"
2223
pg_logfile="{{pg_datadir}}/pg.log"
@@ -31,7 +32,7 @@ shardman_repo=https://github.com/postgrespro/pg_shardman.git
3132
shardman_src="{{pg_prefix}}/pg_shardman"
3233
shardman_version_tag=master
3334

34-
cflags="-O0"
35+
shardman_shardlord_connstring="host={{ shardlord_ip }} port={{ pg_port }} user={{ ansible_user }}"
3536

3637
[nodes:children]
3738
ec2
@@ -55,10 +56,16 @@ manual_init_node
5556

5657
# empty groups to be able to run without ec2/manual inventories
5758
[ec2]
59+
[ec2:vars]
60+
# for ec2, take private ip
61+
shardlord_ip="{{ hostvars[groups['shardlord'][0]]['ec2_private_ip_address'] }}"
5862
[ec2_shardlord]
5963
[ec2_workers]
6064
[ec2_init_node]
6165
[manual]
66+
[manual:vars]
67+
# for manual, use just ip specified in inventory
68+
shardlord_ip="{{ groups['shardlord'][0] }}"
6269
[manual_shardlord]
6370
[manual_workers]
6471
[manual_init_node]

devops/inventory_manual/manual

Lines changed: 0 additions & 16 deletions
This file was deleted.

devops/readme.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ ansible-playbook -i inventory_ec2 pg_ctl.yml -e "pg_ctl_action=restart"
5151

5252
Read cmd log on shardlord:
5353
ansible-playbook -i inventory_ec2/ psql.yml --limit 'shardlord' -e "cmd='\'table shardman.cmd_log\''"
54+
Read nodes table on workers:
55+
nodes': ansible-playbook -i inventory_manual/ psql.yml --limit 'workers' -e "cmd='\'table shardman.nodes\''"
5456

5557
Gather logs to ./logs:
5658
ansible-playbook -i inventory_ec2/ logs.yml
@@ -67,6 +69,8 @@ Things that made me wonder during writing this:
6769
why projects like
6870
https://github.com/larsks/ansible-toolbox
6971
emerge. Printing cmd output via saved var is pretty horrible too.
72+
* They also try to reinvent all the concepts of normal languages in YML. How
73+
about infinite repeat..until?
7074
* No way to specify multiple inventory files, only whole directory or one file.
7175
* No way to append file to file, except for j2 templates, which doesn't work
7276
with files outside the template dir, really?

devops/templates/postgresql.conf.lord.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
{% include "postgresql.conf.lord" ignore missing %}
77

8+
shardman.shardlord_connstring = '{{ shardman_shardlord_connstring }}'
9+
810
{% include "postgresql.conf.devops.common" ignore missing %}
911

1012
{% include "postgresql.conf.devops.lord" ignore missing %}

0 commit comments

Comments
 (0)