/images/avatar.jpeg

[ansible]Ansible with bastian host

How to run ansible commands with servers behind bastian-host Create ssh custom config file ssh.config Host bastion HostName bastian_server_ip User my_user ProxyCommand none IdentityFile ~/.ssh/id_rsa BatchMode yes PasswordAuthentication no Host * ServerAliveInterval 60 TCPKeepAlive yes ProxyCommand ssh -q -A my_user@bastian_server_ip nc %h %p ControlPath ~/.ssh/mux-%r@%h:%p User my_user ControlMaster auto now we can connect to host behind bastian host with this command : ssh -F ssh.config host_private_ip Create ansible custom config file ansible.

[bash] Mysql usr/db/psw multiple creation

Script for creation of multiple databases/users on mysql #!/bin/bash file="users_all" while IFS=, read -r user db pswd host do mysql -e "CREATE USER '$user'@'$host';" mysql -e "CREATE DATABASE $db;" mysql -e "GRANT ALL PRIVILEGES ON $db.* TO '$user'@'$host' IDENTIFIED BY '$pswd';" done <"$file" file with parameters (users_all) user01,db01,psw01,host01 user02,db02,psw02,host02