FastHandle - IT Operations Examples

FastHandle is fast operation tools for infrastructure configurations and tests.

User Tools

Site Tools


Sidebar


Top     SiteMap

Manager Server

Target Server

$FHHOME/bin/xxx.sh | xxxx.exp













.

appendix:fabric-vs-others.html



Top#Appendix

Python Fabric vs Other Tools

Python Fabric vs Only ssh

  • FastHandle can easily deploy many servers.
  • FastHandle keep Password and PublicKey and Passphrase
  • FastHandle can use ' and “ like local server.

$ fab -H x.x.x.x auth.pro -- hostname
$ fab -H x.x.x.x auth.stg -- hostname

vs

$ ssh x.x.x.x hostname
$ ssh -i ~/.ssh/id_rsa.pro x.x.x.x hostname
$ ssh -i ~/.ssh/id_rsa.stg x.x.x.x hostname

$ fab -H x.x.x.x auth.pro -- "echo "any host 192.168.100.1 gw 192.168.0.5" >> /etc/sysconfig/static-routes"
$ fab -H x.x.x.x auth.pro -- "echo 'any host 192.168.100.1 gw 192.168.0.5' >> /etc/sysconfig/static-routes"

vs

$ ssh -t x.x.x.x sudo "bash -c 'echo \"any host 192.168.100.1 gw 192.168.0.5\" >> /etc/sysconfig/static-routes'"

$ fab  -H x.x.x.x auth.pro -- "sed s/192.168.100.10/192.168.50.10/g /etc/hosts > /etc/hosts.`date '+%Y%m%d'`"

vs

$ ssh x.x.x.x  sudo "bash -c 'sed s/192.168.100.10/192.168.50.10/g /etc/hosts > /etc/hosts.`date '+%Y%m%d'`' "

$ H="192.168.0.1,192.168.0.2"
$ fab -H $H  auth.pro -- hostname

vs

$ H="192.168.0.1 192.168.0.2"
$ for i in $H ; do ssh -n $i "hostname" ; done


Ansible Ad-Hoc Commands

http://docs.ansible.com/ansible/latest/intro_adhoc.html

  • Ansible must be aware of the initial connection “yes/no”.

Ansible Options

$ ansible -h
Usage: ansible <host-pattern> [options]

Options:
  -a MODULE_ARGS, --args=MODULE_ARGS
                        module arguments
  --ask-vault-pass      ask for vault password

  -i INVENTORY, --inventory-file=INVENTORY
                        specify inventory host path
                        (default=/etc/ansible/hosts) or comma separated host
                        list.
  -m MODULE_NAME, --module-name=MODULE_NAME
                        module name to execute (default=command)

  Connection Options:
    -k, --ask-pass      ask for connection password
    --private-key=PRIVATE_KEY_FILE, --key-file=PRIVATE_KEY_FILE
    -u REMOTE_USER, --user=REMOTE_USER
                        connect as this user (default=None)

  Privilege Escalation Options:
    -s, --sudo          run operations with sudo (nopasswd) (deprecated, use
                        become)
    -U SUDO_USER, --sudo-user=SUDO_USER
                        desired sudo user (default=root) (deprecated, use
                        become)
    -S, --su            run operations with su (deprecated, use become)
    --ask-sudo-pass     ask for sudo password (deprecated, use become)
    --ask-su-pass       ask for su password (deprecated, use become)

Example

$ ansible -i 127.0.0.1, all  -u user01 -k -a "hostname"

$ ansible -i 127.0.0.1, all  -u root -k -a "whoami"
SSH password:
127.0.0.1 | SUCCESS | rc=0 >>
root

$ vi hosts_test
[test-web]
192.168.0.10
192.168.0.11

$ ansible test-web -i hosts_test -a 'hostname'

$ ansible -i hosts_test  -u user01 -k -s -a "cat /etc/shadow"

$ ansible -s -K -B 1 -a "shutdown -h now" -i host1,host2 all




Top#Appendix



appendix/fabric-vs-others.html.txt · Last modified: 2018/02/24 02:37 by kurihara