diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 0000000..356424a --- /dev/null +++ b/ansible/ansible.cfg @@ -0,0 +1,7 @@ +[defaults] + +# problem with 'create_db' 'Ensure database is created' +# @see https://github.com/georchestra/ansible/issues/55 +# Have to make temorary files readable by all, beacuse when chaning user +# -> that use does not have access to temp file ( run scripts ) +allow_world_readable_tmpfiles=true \ No newline at end of file diff --git a/ansible/ansible.md b/ansible/ansible.md new file mode 100644 index 0000000..8f8a692 --- /dev/null +++ b/ansible/ansible.md @@ -0,0 +1,7 @@ +# Ansible + +Ansible file taken from: server-tools + +This will instlal `serversdk` test database on `spaceti-experimental` + +`ansible/playbook.sh install-postgres` diff --git a/ansible/install-postgres.yml b/ansible/install-postgres.yml new file mode 100644 index 0000000..92e4353 --- /dev/null +++ b/ansible/install-postgres.yml @@ -0,0 +1,8 @@ +- hosts: db + become: yes + vars_files: + - postgresql/vars.yml + vars: + + roles: + - geerlingguy.postgresql diff --git a/ansible/inventory.yml b/ansible/inventory.yml new file mode 100644 index 0000000..4b26972 --- /dev/null +++ b/ansible/inventory.yml @@ -0,0 +1,10 @@ +--- + +db: + hosts: + spaceti-experimental: + ansible_host: 192.168.1.94 + server_name: 'spaceti-experimental' + ansible_user: 'filip' + ansible_private_key_file: '~/.ssh/spaceti_gitlab' + # ansible_python_interpreter: '/usr/bin/python' \ No newline at end of file diff --git a/ansible/playbook.sh b/ansible/playbook.sh new file mode 100755 index 0000000..e5fd340 --- /dev/null +++ b/ansible/playbook.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +cd $SRCDIR +ansible-playbook -i inventory.yml $1.yml diff --git a/ansible/postgresql/vars.yml b/ansible/postgresql/vars.yml new file mode 100644 index 0000000..d511c31 --- /dev/null +++ b/ansible/postgresql/vars.yml @@ -0,0 +1,19 @@ + +no_log: no +postgresql_databases: + - name: serversdk +postgresql_users: + - name: postgres + password: 34rjkciea12 +postgresql_group: postgres +postgresql_global_config_options: + - option: listen_addresses + value: '*' +postgresql_hba_entries: + - { type: local, database: all, user: postgres, auth_method: peer } + - { type: local, database: all, user: all, auth_method: peer } + - { type: host, database: all, user: all, address: '127.0.0.1/32', auth_method: md5 } + - { type: host, database: all, user: all, address: '::1/128', auth_method: md5 } + - { type: host, database: all, user: all, address: '0.0.0.0/0', auth_method: md5 } # full access + # - { type: host, database: all, user: all, address: '178.209.130.196/32', auth_method: md5 } # access from specific IP only +postgresql_restarted_state: "restarted"