From de7a5fdf27bd2e6e5f2c267082b00bc6dfc10418 Mon Sep 17 00:00:00 2001 From: Oliver Rice Date: Tue, 2 Aug 2022 10:24:38 -0500 Subject: [PATCH 1/8] install pg_jsonschema v0.1.0 --- .../postgres-extensions/21-pg_jsonschema.yml | 51 +++++++++++++++++++ ansible/tasks/setup-extensions.yml | 3 ++ ansible/vars.yml | 3 ++ 3 files changed, 57 insertions(+) create mode 100644 ansible/tasks/postgres-extensions/21-pg_jsonschema.yml diff --git a/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml b/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml new file mode 100644 index 000000000..b4a0bd023 --- /dev/null +++ b/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml @@ -0,0 +1,51 @@ +# pg_jsonschema +- name: pg_jsonschema - download & install dependencies + apt: + pkg: + - make + - gcc + - pkg-config + - clang + - postgresql-server-dev-{{ postgresql_major }} + - libssl-dev + update_cache: yes + install_recommends: no + +- name: check if cargo is installed + shell: command -v cargo + register: cargo_exists + ignore_errors: yes + +- name: download rust/cargo installer + when: cargo_exists is failed + get_url: + url: https://sh.rustup.rs + dest: /tmp/sh.rustup.rs + mode: '0755' + force: 'yes' + tags: + - rust + +- name: install rust/cargo + when: cargo_exists is failed + shell: /tmp/sh.rustup.rs -y + tags: + - rust + +- name: install cargo-pgx + shell: + cmd: "cargo install --version '={{ pgx_version }}' cargo-pgx && cargo pgx init --pg{{ postgres_major }} pg_config" + become: yes + +- name: pg_jsonschema - download release + git: + repo: https://github.com/supabase/pg_jsonschema.git + dest: /tmp/pg_jsonschema + version: "{{ pg_jsonschema_release }}" + become: yes + +- name: pg_jsonschema - install + shell: + cmd: "cargo pgx install --release" + chdir: /tmp/pg_jsonschema + become: yes diff --git a/ansible/tasks/setup-extensions.yml b/ansible/tasks/setup-extensions.yml index e6acef402..d16737316 100644 --- a/ansible/tasks/setup-extensions.yml +++ b/ansible/tasks/setup-extensions.yml @@ -57,3 +57,6 @@ - name: Install pg_stat_monitor import_tasks: tasks/postgres-extensions/20-pg_stat_monitor.yml + +- name: Install pg_jsonschema + import_tasks: tasks/postgres-extensions/21-pg_jsonschema.yml diff --git a/ansible/vars.yml b/ansible/vars.yml index 0c9412490..c8e0a8194 100644 --- a/ansible/vars.yml +++ b/ansible/vars.yml @@ -98,4 +98,7 @@ libgraphqlparser_commit_sha: 3b64cd52d13621921990a5801ba019e8a9402599 pg_graphql_release: "v0.3.2" +pgx_version: "0.4.5" +pg_jsonschema_release: "v0.1.0" + pg_stat_monitor_release: "1.0.1" From 7062c0bb8ec033fda4dddfda5b252eb61023ba00 Mon Sep 17 00:00:00 2001 From: Oliver Rice Date: Tue, 2 Aug 2022 10:26:52 -0500 Subject: [PATCH 2/8] tabs to spaces --- .../.21-pg_jsonschema.yml.swp | Bin 0 -> 12288 bytes .../postgres-extensions/21-pg_jsonschema.yml | 12 ++++++------ 2 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 ansible/tasks/postgres-extensions/.21-pg_jsonschema.yml.swp diff --git a/ansible/tasks/postgres-extensions/.21-pg_jsonschema.yml.swp b/ansible/tasks/postgres-extensions/.21-pg_jsonschema.yml.swp new file mode 100644 index 0000000000000000000000000000000000000000..39f03fab2fe3867cde5254aedec6e7989a448a08 GIT binary patch literal 12288 zcmeI2KWiLE7>CDh0{$yvT)2B9fkcYEm1K;SgA_4oY)Bb52^@2~b9-y;?yP6#q!YFh z2!tqw@dpU0(xhT$ zVEDO?M!71S4eh9ueQ8x#YU>iCY$ywx_A?baX*X^AI8bA!P@@YQuCE1U(z{{tIU1^5 zc6RdYja_pk8#vkqMs5&noE8_?*H*oVrNxiv+=pKtZ6`c>Hoykh02^QfY=8~00XA^N z47l=`_!eV6UXS}?eLr^SUKjbs2G{@_U;}J`4X^<=zy{a=8(;%$fDOEd24pP6-4jA= zpG5Nb{lEGD|LIvF9)SDcSMU?K3vPn~d;*ri0(fyoi09x5_yhb5_P`H7f-B%MxBywn@6@)7q#;NI2=<+h0Iomp^&EqaD zM$#mj%4AGwVV%q}3Id}th10W(2(v?#WnB?aA$`j;tx(XsBM^DGa~$*a2W!#Aty{D2 z_3HL%ch`486f5iIrfF2EyEJsJwB0aFQa2p+I~eEGA>Wx}yNE!e_&Y!ASZ^1ZmNC_d zye|D{%FcnAdQi0TX*H;EuX(V$yF!&p93mdm^75omdrcjrmWh9*K9AhXnUEC*=G?`~R?D*PI*)f)a9n@|Q6=tDoqo>BHb(T^~ z1DR$jZYQ?s%D)>{v2*$&8fX(?DXd_Xt)O|LT*tn=dim0&$%Co+oKB|-9+~W5HV@S% z%JqCb0^cg>gL!PTZdRl+KL0c+v{5}AIM>ED`@*OM5)?MZv=c1y&g>F<%=@EuWiNyMWr4A{>=Z+ETfh1e0~uK1!mf{hZ59RTU8Db<6T?w##xe TVC>iu!&60+;;Uw9c6*Cg8=TWv literal 0 HcmV?d00001 diff --git a/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml b/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml index b4a0bd023..7b0c73c33 100644 --- a/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml +++ b/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml @@ -19,18 +19,18 @@ - name: download rust/cargo installer when: cargo_exists is failed get_url: - url: https://sh.rustup.rs - dest: /tmp/sh.rustup.rs - mode: '0755' - force: 'yes' + url: https://sh.rustup.rs + dest: /tmp/sh.rustup.rs + mode: '0755' + force: 'yes' tags: - - rust + - rust - name: install rust/cargo when: cargo_exists is failed shell: /tmp/sh.rustup.rs -y tags: - - rust + - rust - name: install cargo-pgx shell: From eb52adcc170d0e339a0b7c922ed7b05b213c26f2 Mon Sep 17 00:00:00 2001 From: Oliver Rice Date: Fri, 5 Aug 2022 10:38:13 -0500 Subject: [PATCH 3/8] Update ansible/tasks/postgres-extensions/21-pg_jsonschema.yml Co-authored-by: dragarcia --- ansible/tasks/postgres-extensions/21-pg_jsonschema.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml b/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml index 7b0c73c33..38f0c6e03 100644 --- a/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml +++ b/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml @@ -34,7 +34,7 @@ - name: install cargo-pgx shell: - cmd: "cargo install --version '={{ pgx_version }}' cargo-pgx && cargo pgx init --pg{{ postgres_major }} pg_config" + cmd: "~/.cargo/bin/cargo install --version '={{ pgx_version }}' cargo-pgx && ~/.cargo/bin/cargo pgx init --pg{{ postgres_major }} pg_config" become: yes - name: pg_jsonschema - download release From 1d4f7f058eea2fbc21fafaf46be52416d81d31cf Mon Sep 17 00:00:00 2001 From: Oliver Rice Date: Fri, 5 Aug 2022 10:38:22 -0500 Subject: [PATCH 4/8] Update ansible/tasks/postgres-extensions/21-pg_jsonschema.yml Co-authored-by: dragarcia --- ansible/tasks/postgres-extensions/21-pg_jsonschema.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml b/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml index 38f0c6e03..2978e10bc 100644 --- a/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml +++ b/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml @@ -46,6 +46,6 @@ - name: pg_jsonschema - install shell: - cmd: "cargo pgx install --release" + cmd: "~/.cargo/bin/cargo pgx install --release" chdir: /tmp/pg_jsonschema become: yes From ff6be94b10b8cb9e6a9c6ccbdf11f99120c582c1 Mon Sep 17 00:00:00 2001 From: Oliver Rice Date: Fri, 5 Aug 2022 10:42:52 -0500 Subject: [PATCH 5/8] remove and ignore swp files --- .gitignore | 1 + ansible/tasks/.setup-extensions.yml.swp | Bin 12288 -> 0 bytes .../.21-pg_jsonschema.yml.swp | Bin 12288 -> 0 bytes 3 files changed, 1 insertion(+) delete mode 100644 ansible/tasks/.setup-extensions.yml.swp delete mode 100644 ansible/tasks/postgres-extensions/.21-pg_jsonschema.yml.swp diff --git a/.gitignore b/.gitignore index 8c1f8fabd..b4a2fc6df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .DS_Store .python-version venv/ +*.swp diff --git a/ansible/tasks/.setup-extensions.yml.swp b/ansible/tasks/.setup-extensions.yml.swp deleted file mode 100644 index a2a6c5b570acf16d64e8aa6a8a976f49704ba135..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2y=xRf7>6ekjV4CL572JadUGGqcm|@VDNG^S7&R%5x!bwBO=dr`J9~))6gykN zLeL@#HVWGM39;~xu(Pm8W1)p$;m2?8E_yk3g~3XB2OgHaclhn>v-jR{+*I<@Q|GMG zNReUeVyu7sW999;4+G0*`&b~|ridc9Ds(Y>V4m$2!V$^+>`ACx`yH5@462DId==;7 zB;*wyi(DAQsve0r$Nku?NRd-Ko=07%B(%kn5_mcA?9wnB zEf(^+bokIgYtQbBy|d_?43GgbKnBPF86X2>fDDj<|JZ;E``C5d-=@wzp6VR?dXAk_ zI*fDDiUGC&5%02v?y|DXZxFm_{rvHM%Gc>Mpr{`-GzCu2{+6L1?` z0hhsPFa!p{=N*ha2hYF?sDm1~01klt;M*``Z@?;e0IHw@Cc$RV57xFb_82?@x4fDHV#ffMavIie}#hLa#<6Yaq)%W}Oih*Y_? z8*toeZwg%BE7-L!Fjp+tVZA&TV~=39Aw1sNC}>+g_r$n0<;RLkX>FLn5O0vq6BU%j zQYg9Wr-pY=Fv`yBm1BXb>;=B7f+#hJbkc3ojH}Nu3 z+eM?yV|uL(9yeU4z1uV8A$H0}xnp*eu}r*flyp?D&=)G>o^{D6?}*OB`^qoZT&YCn z2kSrSn(N<&B0qaabPU(a|f UovKkPz76$;dN<=Ev|VFA0cU{>F8}}l diff --git a/ansible/tasks/postgres-extensions/.21-pg_jsonschema.yml.swp b/ansible/tasks/postgres-extensions/.21-pg_jsonschema.yml.swp deleted file mode 100644 index 39f03fab2fe3867cde5254aedec6e7989a448a08..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2KWiLE7>CDh0{$yvT)2B9fkcYEm1K;SgA_4oY)Bb52^@2~b9-y;?yP6#q!YFh z2!tqw@dpU0(xhT$ zVEDO?M!71S4eh9ueQ8x#YU>iCY$ywx_A?baX*X^AI8bA!P@@YQuCE1U(z{{tIU1^5 zc6RdYja_pk8#vkqMs5&noE8_?*H*oVrNxiv+=pKtZ6`c>Hoykh02^QfY=8~00XA^N z47l=`_!eV6UXS}?eLr^SUKjbs2G{@_U;}J`4X^<=zy{a=8(;%$fDOEd24pP6-4jA= zpG5Nb{lEGD|LIvF9)SDcSMU?K3vPn~d;*ri0(fyoi09x5_yhb5_P`H7f-B%MxBywn@6@)7q#;NI2=<+h0Iomp^&EqaD zM$#mj%4AGwVV%q}3Id}th10W(2(v?#WnB?aA$`j;tx(XsBM^DGa~$*a2W!#Aty{D2 z_3HL%ch`486f5iIrfF2EyEJsJwB0aFQa2p+I~eEGA>Wx}yNE!e_&Y!ASZ^1ZmNC_d zye|D{%FcnAdQi0TX*H;EuX(V$yF!&p93mdm^75omdrcjrmWh9*K9AhXnUEC*=G?`~R?D*PI*)f)a9n@|Q6=tDoqo>BHb(T^~ z1DR$jZYQ?s%D)>{v2*$&8fX(?DXd_Xt)O|LT*tn=dim0&$%Co+oKB|-9+~W5HV@S% z%JqCb0^cg>gL!PTZdRl+KL0c+v{5}AIM>ED`@*OM5)?MZv=c1y&g>F<%=@EuWiNyMWr4A{>=Z+ETfh1e0~uK1!mf{hZ59RTU8Db<6T?w##xe TVC>iu!&60+;;Uw9c6*Cg8=TWv From 7d18f9310d0e0d062d83508cebe4e23afc7fce0d Mon Sep 17 00:00:00 2001 From: Oliver Rice Date: Fri, 5 Aug 2022 10:45:24 -0500 Subject: [PATCH 6/8] pg_jsonschema task 21 -> 22 --- .../{21-pg_jsonschema.yml => 22-pg_jsonschema.yml} | 11 ----------- ansible/tasks/setup-extensions.yml | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) rename ansible/tasks/postgres-extensions/{21-pg_jsonschema.yml => 22-pg_jsonschema.yml} (82%) diff --git a/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml b/ansible/tasks/postgres-extensions/22-pg_jsonschema.yml similarity index 82% rename from ansible/tasks/postgres-extensions/21-pg_jsonschema.yml rename to ansible/tasks/postgres-extensions/22-pg_jsonschema.yml index 2978e10bc..8d45e74c5 100644 --- a/ansible/tasks/postgres-extensions/21-pg_jsonschema.yml +++ b/ansible/tasks/postgres-extensions/22-pg_jsonschema.yml @@ -11,26 +11,15 @@ update_cache: yes install_recommends: no -- name: check if cargo is installed - shell: command -v cargo - register: cargo_exists - ignore_errors: yes - - name: download rust/cargo installer - when: cargo_exists is failed get_url: url: https://sh.rustup.rs dest: /tmp/sh.rustup.rs mode: '0755' force: 'yes' - tags: - - rust - name: install rust/cargo - when: cargo_exists is failed shell: /tmp/sh.rustup.rs -y - tags: - - rust - name: install cargo-pgx shell: diff --git a/ansible/tasks/setup-extensions.yml b/ansible/tasks/setup-extensions.yml index 03c1c9aa2..15b6b5b76 100644 --- a/ansible/tasks/setup-extensions.yml +++ b/ansible/tasks/setup-extensions.yml @@ -62,4 +62,4 @@ import_tasks: tasks/postgres-extensions/21-auto_explain.yml - name: Install pg_jsonschema - import_tasks: tasks/postgres-extensions/21-pg_jsonschema.yml + import_tasks: tasks/postgres-extensions/22-pg_jsonschema.yml From 20358d4f5c48e8c20710fdde9a0a0f2511842567 Mon Sep 17 00:00:00 2001 From: Oliver Rice Date: Fri, 5 Aug 2022 11:21:02 -0500 Subject: [PATCH 7/8] bump img version --- common.vars.pkr.hcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.vars.pkr.hcl b/common.vars.pkr.hcl index 7747a1692..167730361 100644 --- a/common.vars.pkr.hcl +++ b/common.vars.pkr.hcl @@ -1 +1 @@ -postgres-version = "14.1.0.50" +postgres-version = "14.1.0.51" From 9e64b30377e7812bea02b958fca6d2b3b4bd78d3 Mon Sep 17 00:00:00 2001 From: dragarcia Date: Mon, 8 Aug 2022 16:04:47 +0800 Subject: [PATCH 8/8] remaining steps - ensure certain steps are run by the postgres Linux user - temporarily grant ownership for certain directories to the postgres Linux user --- .../postgres-extensions/22-pg_jsonschema.yml | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/ansible/tasks/postgres-extensions/22-pg_jsonschema.yml b/ansible/tasks/postgres-extensions/22-pg_jsonschema.yml index 8d45e74c5..1052ad86f 100644 --- a/ansible/tasks/postgres-extensions/22-pg_jsonschema.yml +++ b/ansible/tasks/postgres-extensions/22-pg_jsonschema.yml @@ -6,35 +6,57 @@ - gcc - pkg-config - clang - - postgresql-server-dev-{{ postgresql_major }} - libssl-dev update_cache: yes install_recommends: no - name: download rust/cargo installer + become: yes get_url: url: https://sh.rustup.rs dest: /tmp/sh.rustup.rs mode: '0755' - force: 'yes' + owner: postgres + group: postgres - name: install rust/cargo + become: yes + become_user: postgres shell: /tmp/sh.rustup.rs -y - name: install cargo-pgx - shell: - cmd: "~/.cargo/bin/cargo install --version '={{ pgx_version }}' cargo-pgx && ~/.cargo/bin/cargo pgx init --pg{{ postgres_major }} pg_config" become: yes + become_user: postgres + shell: + cmd: "~/.cargo/bin/cargo install --version '={{ pgx_version }}' cargo-pgx && ~/.cargo/bin/cargo pgx init --pg{{ postgresql_major }} pg_config" - name: pg_jsonschema - download release + become: yes git: repo: https://github.com/supabase/pg_jsonschema.git dest: /tmp/pg_jsonschema version: "{{ pg_jsonschema_release }}" - become: yes + +- name: pg_jsonschema - temporarily transfer ownership to postgres + file: + path: '{{ item }}' + recurse: yes + owner: postgres + group: postgres + with_items: + - /tmp/pg_jsonschema + - /usr/lib/postgresql/lib - name: pg_jsonschema - install + become: yes + become_user: postgres shell: cmd: "~/.cargo/bin/cargo pgx install --release" chdir: /tmp/pg_jsonschema - become: yes + +- name: pg_jsonschema - return ownership to root + file: + path: /usr/lib/postgresql/lib + recurse: yes + owner: root + group: root