您好,登錄后才能下訂單哦!
本篇內容主要講解“ansible的安裝方法與基本使用”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“ansible的安裝方法與基本使用”吧!
服務端安裝ansible
[root@k8s-mater]yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm [root@k8s-mater]yum install ansible -y [root@k8s-master ansible]# ansible --help Usage: ansible <host-pattern> [options] Options: -a MODULE_ARGS, --args=MODULE_ARGS module arguments -k, --ask-pass ask for SSH password --ask-su-pass ask for su password -K, --ask-sudo-pass ask for sudo password --ask-vault-pass ask for vault password -B SECONDS, --background=SECONDS run asynchronously, failing after X seconds (default=N/A) -C, --check don't make any changes; instead, try to predict some of the changes that may occur -c CONNECTION, --connection=CONNECTION connection type to use (default=smart) -f FORKS, --forks=FORKS specify number of parallel processes to use (default=5) -h, --help show this help message and exit -i INVENTORY, --inventory-file=INVENTORY specify inventory host file (default=/etc/ansible/hosts) -l SUBSET, --limit=SUBSET further limit selected hosts to an additional pattern --list-hosts outputs a list of matching hosts; does not execute anything else -m MODULE_NAME, --module-name=MODULE_NAME module name to execute (default=command) -M MODULE_PATH, --module-path=MODULE_PATH specify path(s) to module library (default=/usr/share/ansible/) -o, --one-line condense output -P POLL_INTERVAL, --poll=POLL_INTERVAL set the poll interval if using -B (default=15) --private-key=PRIVATE_KEY_FILE use this file to authenticate the connection -S, --su run operations with su -R SU_USER, --su-user=SU_USER run operations with su as this user (default=root) -s, --sudo run operations with sudo (nopasswd) -U SUDO_USER, --sudo-user=SUDO_USER desired sudo user (default=root) -T TIMEOUT, --timeout=TIMEOUT override the SSH timeout in seconds (default=10) -t TREE, --tree=TREE log output to this directory -u REMOTE_USER, --user=REMOTE_USER connect as this user (default=root) --vault-password-file=VAULT_PASSWORD_FILE vault password file -v, --verbose verbose mode (-vvv for more, -vvvv to enable connection debugging) --version show program's version number and exit
配置hosts,便于后續操控遠程主機
cd /etc/ansible vim hosts ## db-[99:101]-node.example.com 192.168.189.89
編輯/etc/ansible/ansible.cfg
inventory = /etc/ansible/hosts #將注釋#去掉
測試命令
[root@k8s-master ansible]# ansible localhost -m ping localhost | SUCCESS => { "changed": false, "ping": "pong" } [root@k8s-master ansible]# ansible localhost -m command -a "df -h" localhost | CHANGED | rc=0 >> 文件系統 容量 已用 可用 已用% 掛載點 /dev/mapper/centos-root 17G 5.5G 12G 33% / devtmpfs 475M 0 475M 0% /dev tmpfs 487M 124K 487M 1% /dev/shm tmpfs 487M 14M 473M 3% /run tmpfs 487M 0 487M 0% /sys/fs/cgroup /dev/sda1 1014M 133M 882M 14% /boot tmpfs 98M 0 98M 0% /run/user/0
到此,相信大家對“ansible的安裝方法與基本使用”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。