diff --git a/ansible/install_emulation_system.yml b/ansible/install_emulation_system.yml index 37c2883ca..3e6858a65 100644 --- a/ansible/install_emulation_system.yml +++ b/ansible/install_emulation_system.yml @@ -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 diff --git a/ansible/install_metastore.yml b/ansible/install_metastore.yml index 7c296abab..3bd98037b 100644 --- a/ansible/install_metastore.yml +++ b/ansible/install_metastore.yml @@ -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 @@ -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: diff --git a/ansible/install_metastore_leader.yml b/ansible/install_metastore_leader.yml index 600e63dce..2d6b72851 100644 --- a/ansible/install_metastore_leader.yml +++ b/ansible/install_metastore_leader.yml @@ -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 @@ -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 \ No newline at end of file diff --git a/metastore/create_db.sql b/metastore/create_db.sql index 4c0e219b2..829f6e41d 100644 --- a/metastore/create_db.sql +++ b/metastore/create_db.sql @@ -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;