Skip to content

Commit

Permalink
ansible installation [wip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Limmen committed Mar 10, 2024
1 parent 901b240 commit f4095dc
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 40 deletions.
2 changes: 2 additions & 0 deletions ansible/install_emulation_system.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@
derived_images_pulled: "{{ spark_derived in docker_images_list.stdout }}"

- name: Pulling base Docker images
become: true
shell: "cd /home/{{ user }}/csle/emulation-system/base_images && make pull"
args:
executable: /bin/bash
when: not base_images_pulled

- name: Pulling derived Docker images
become: true
shell: "cd /home/{{ user }}/csle/emulation-system/derived_images && make pull"
args:
executable: /bin/bash
Expand Down
106 changes: 70 additions & 36 deletions ansible/install_metastore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,37 +63,69 @@
become: true
shell: "pg_conftool {{ postgres_version }} main set listen_addresses '*'"

- name: Update local authentication method in postgres config file
become: true
lineinfile:
path: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
regexp: '^local\s+all\s+postgres\s+peer$'
line: "local\tall\t\tpostgres\t\t\t\tmd5"
state: present

- name: Update 127.0.0.1 authentication method in postgres config file
become: true
lineinfile:
path: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
regexp: '^host\s+all\s+all\s+127.0.0.1/32\s+scram-sha-256$'
line: "host\tall\t\tall\t\t127.0.0.1/32\t\ttrust"
state: present

- name: Update general authentication method in postgres config file
become: true
lineinfile:
path: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
regexp: '^host\s+all\s+all\s+::1/128\s+scram-sha-256$'
line: "host\tall\t\tall\t\t::1/128\t\t\ttrust"
state: present

- name: Add trusted subnetwork to postgres config file
become: true
lineinfile:
path: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
line: "host\tall\t\tall\t\t{{ trusted_subnetwork }}\t\ttrust"
insertafter: EOF
state: present
- name: Clear postgres configuration file
become: true
shell: "sudo echo '' > /etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"

- name: Update the postgres configuration file
become: true
shell: "sudo echo 'local\tall\tpostgres\ttrust' > /etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"

- name: Update the postgres configuration file
become: true
shell: "sudo echo 'host\tall\tall\t0.0.0.0/0\ttrust' >> /etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"

- name: Update the postgres configuration file
become: true
shell: "sudo echo 'host\tall\tall\t::1/128\ttrust' >> /etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"

- name: Update the postgres configuration file
become: true
shell: "sudo echo 'host\tall\tall\t127.0.0.0/8\ttrust' >> /etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"

# - name: Update the postgres configuration file
# become: true
# lineinfile:
# dest: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
# line: |
# local all postgres trust
# local all all trust
# host all all 127.0.0.1/32 trust
# host all all ::1/128 trust
# local replication all trust
# host all all {{ trusted_subnetwork }} trust

# - name: Update local authentication method in postgres config file
# become: true
# lineinfile:
# path: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
# regexp: '^local\s+all\s+postgres\s+trust$'
# line: "local\tall\t\tpostgres\t\t\t\ttrust"
# state: present
#
# - name: Update 127.0.0.1 authentication method in postgres config file
# become: true
# lineinfile:
# path: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
# regexp: '^host\s+all\s+all\s+127.0.0.1/32\s+scram-sha-256$'
# line: "host\tall\t\tall\t\t127.0.0.1/32\t\ttrust"
# state: present
#
# - name: Update general authentication method in postgres config file
# become: true
# lineinfile:
# path: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
# regexp: '^host\s+all\s+all\s+::1/128\s+scram-sha-256$'
# line: "host\tall\t\tall\t\t::1/128\t\t\ttrust"
# state: present
#
# - name: Add trusted subnetwork to postgres config file
# become: true
# lineinfile:
# path: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
# line: "host\tall\t\tall\t\t{{ trusted_subnetwork }}\t\ttrust"
# insertafter: EOF
# state: present

- name: Restart postgres
become: true
Expand Down Expand Up @@ -137,30 +169,32 @@
db: postgres
autocommit: yes
login_user: postgres
login_password: "{{ postgres_password }}"
# login_password: "{{ postgres_password }}"
query: "CREATE DATABASE csle"
ignore_errors: true

- name: Setup database privileges
- name: Setup database privileges, if you see error here just ignore it!
become: yes
become_method: sudo
become_user: postgres
community.postgresql.postgresql_script:
db: postgres
login_user: postgres
login_password: "{{ postgres_password }}"
# login_password: "{{ postgres_password }}"
path: /var/lib/postgresql/create_db.sql
ignore_errors: true

- name: Add citus extension
- name: Add citus extension, if you see error here just ignore it!
become: yes
become_method: sudo
become_user: postgres
community.postgresql.postgresql_ext:
login_user: postgres
login_password: "{{ postgres_password }}"
# login_password: "{{ postgres_password }}"
db: csle
name: citus
version: latest
ignore_errors: true

- name: Change mode and ownership of the /var/log/postgresql
file:
Expand Down
4 changes: 2 additions & 2 deletions ansible/install_metastore_leader.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
become_user: postgres
community.postgresql.postgresql_script:
login_user: postgres
login_password: "{{ postgres_password }}"
# login_password: "{{ postgres_password }}"
db: csle
path: /var/lib/postgresql/create_tables.sql
ignore_errors: true
Expand All @@ -65,6 +65,6 @@
become_user: postgres
community.postgresql.postgresql_script:
login_user: postgres
login_password: "{{ postgres_password }}"
# login_password: "{{ postgres_password }}"
db: csle
path: /var/lib/postgresql/create_cluster.sql
4 changes: 2 additions & 2 deletions metastore/create_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
SELECT 'CREATE DATABASE csle' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'csle')\gexec

-- Create csle user --
REASSIGN OWNED BY csle TO postgres;
DROP OWNED BY csle;
DROP USER IF EXISTS csle;
CREATE USER csle WITH ENCRYPTED PASSWORD 'csle';
REASSIGN OWNED BY csle TO postgres;
DROP OWNED BY csle;

-- Grant priviliges to csle user for the csle db --
GRANT ALL PRIVILEGES ON DATABASE csle TO csle;
Expand Down

0 comments on commit f4095dc

Please sign in to comment.