Useful shortcuts for vi editor

Tuesday, 27 August 2019

Ansible Commands Book

-> valid syntax of the playbook
$ ansible-playbook -i myhosts example.yml -v 
--syntax-check

-> show elapsed time of the playbook

$ time ansible-playbook -i myhosts example.yml -v

-> maintain output verbosity (-v, -vv, -vvv, -vvv)
$ time ansible-playbook -i myhosts example.yml -vvvv

-> list tags/tasks of the playbook
$ ansible-playbook -i myhosts example.yml --list-tags
$ ansible-playbook -i myhosts example.yml --list-tasks

-> run the playbook by getting vault password/sudo password from user
$ ansible-playbook -i myhosts example.yml --ask-vault-pass
$ ansible-playbook -i myhosts example.yml --ask-sudo-pass

-> run the playbook with sudo password 
$ ansible-playbook -i myhosts example.yml -e "ansible_sudo_pass=alper"
(-e, --extra-vars)

How to drop database/user on logical replicated database?

1st step
on 2nd node:
$ echo "DROP SUBSCRIPTION exampledb_node_2" | psql

on 1st node:
$ echo "DROP PUBLICATION exampledb_node_1" | psql

2nd step
on 1st node:
$ echo -e "DROP DATABASE exampledb \n" | psql
$ echo "DROP USER \"user-example\"" | psql

on 2nd node:
$ echo -e "DROP DATABASE exampledb \n" | psql
$ echo "DROP USER \"user-example\"" | psql