<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                一、Ansible基礎 1、ansible簡介 2、Ansible優點 * Ansible柔和了眾多其他運維工具的優先,比如pubbet和saltstack能實現的功能,Ansible的都能實現 * Ansible是一款輕量級,無需再客戶端安裝agent * Ansibe其實只是一個工具,Ansible不需要啟動服務,僅僅是一個工具,可以輕松的實現分布式擴展 * 批量任何執行可以寫成腳本,而且不用分發到遠程就可以執行 * Ansible是一款高可靠性,輕量級的自動化工具 * Ansible使用python語言開發 3、Ansible特性: * no agents 不需要再被管控知己上安裝任何客戶端 * no server 無服務端 * modules in any languages 基于模塊工作,可以使用任意語言開發 * yaml 使用yaml語言定制劇本playbook * ssh by default 基于ssh工作(默認) 4、Ansible的基本框架 ![](https://box.kancloud.cn/1269092a2e12f539b3835704484435c5_539x273.png) ![](https://box.kancloud.cn/537e6f3a89241e65f4b267a1a09ebbd1_717x475.png) 二、Ansible的安裝 1)centos系統上安裝 * 直接yum安裝即可 安裝之前先查看系統自帶的ansible版本,看是否滿足需求,如果滿足需求,就沒必要安裝最新版本,直接執行yum -y install ansible即可 ~~~ [admin@node1 ~]$ sudo yum info ansible Loaded plugins: fastestmirror Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.163.com Available Packages Name : ansible Arch : noarch Version : 2.4.1.0 Release : 1.el7 Size : 7.6 M Repo : extras/7/x86_64 Summary : SSH-based configuration management, deployment, and task execution system URL : http://ansible.com License : GPLv3+ Description : : Ansible is a radically simple model-driven configuration management, : multi-node deployment, and remote task execution system. Ansible works : over SSH and does not require any software or daemons to be installed : on remote nodes. Extension modules can be written in any language and : are transferred to managed machines automatically. [admin@node1 ~]$ sudo yum -y install ansible ~~~ 2、ubunt16.04系統上安裝 ~~~ www@u-node1:~$ sudo apt-get update [sudo] password for www: www@u-node1:~$ sudo apt-get -y install software-properties-common www@u-node1:~$ sudo add-apt-repository ppa:ansible/ansible www@u-node1:~$ sudo add-apt update www@u-node1:~$ sudo add-apt -y install ansible ~~~ 三、配置基于密鑰的認證 1、在centos7系統上操作 ~~~ * 在管理端,指定用戶下,生成密鑰對,然后把公鑰發送到被管理端 [admin@node1 ~]$ ssh-keygen -t rsa 然后把公鑰發到各客戶端相應用戶的家目錄下 [admin@node1 ~]$ for i in 130 131 132 135;do ssh-copy-id -i ~/.ssh/id_rsa.pub admin@192.168.20.$i;done ~~~ 2、在ubuntu16.04-server系統上 ~~~ www@u-node1:~$ ssh-keygen -t rsa -P '' 發送公鑰到對應客戶端上 www@u-node1:~$ ssh-copy-id -i .ssh/id_rsa.pub www@192.168.20.157 www@u-node1:~$ ssh-copy-id -i .ssh/id_rsa.pub www@192.168.20.156 www@u-node1:~$ ssh-copy-id -i .ssh/id_rsa.pub www@192.168.20.155 測試: www@u-node1:~$ ssh www@192.168.20.157 'ifconfig' www@u-node1:~$ ssh www@192.168.20.157 'uptime' 21:21:20 up 9 min, 2 users, load average: 0.00, 0.06, 0.06 www@u-node1:~$ ssh www@192.168.20.156 'uptime' 21:21:24 up 9 min, 2 users, load average: 0.00, 0.07, 0.07 www@u-node1:~$ ssh www@192.168.20.155 'uptime' 21:21:27 up 28 min, 2 users, load average: 0.08, 0.06, 0.05 ~~~ 四、命令 1、簡單定義主機清單(詳細見第二章) * 在centos7上 ~~~ [admin@node2 ~]$ cd /etc/ansible/ [admin@node2 ansible]$ cp hosts{,.ori} [admin@node2 ansible]$> hosts [admin@node2 ansible]$ sudo vim hosts 先把原先的所有的先刪掉,然后填寫如下,案例 [admin@node2 ansible]$ sudo vim hosts [websrvs] 192.168.20.153 192.168.20.154 [nosqlsrvs] 192.168.20.152 [dbsrvs] 192.168.20.139 192.168.20.154 ~~~ * 在ubuntu16.04server上操作 ~~~ www@u-node1:~$ cd /etc/ansible/ www@u-node1:/etc/ansible$ sudo cp hosts{,.ori} [sudo] password for www: www@u-node1:/etc/ansible$ sudo vim hosts [websrvs] 192.168.20.155 192.168.20.156 [dbsrvs] 192.168.20.156 192.168.20.157 ~~~ 2、ansible命令 查看幫助 ansible -h 常用選項如下 ~~~ -m module 選擇執行的模塊 -a args 相應模塊的參數 -f FORKS 指定并行進程數 默認為5 -e EXTRA_VARS 設置額外的變量 -b, --become run operations with become -K, --ask-become-pass ask for privilege escalation password ~~~ 案例:批量執行命令,查看各管理端的硬盤使用情況 ~~~ [admin@node1 ~]$ ansible 192.168.20.131 -m command -a 'df -h' 192.168.20.131 | SUCCESS | rc=0 >> Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 13G 1.5G 12G 12% / devtmpfs 486M 0 486M 0% /dev tmpfs 497M 0 497M 0% /dev/shm tmpfs 497M 6.6M 490M 2% /run tmpfs 497M 0 497M 0% /sys/fs/cgroup /dev/vda1 1014M 121M 894M 12% /boot tmpfs 100M 0 100M 0% /run/user/0 tmpfs 100M 0 100M 0% /run/user/1010 ~~~ [admin@node1 ansible]$ ansible webserver -a "wget -O /tmp/EasyRSA-2.2.2.tgz http://soft.51yuki.cn/EasyRSA-2.2.2.tgz"
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看