亚洲全黄无码一级在线看_国产剧情久久久性色_无码av一区二区三区无码_亚洲成a×人片在线观看

當(dāng)前位置: 首頁 > 科技新聞 >

Ansible-安裝配置

時(shí)間:2020-06-30 16:58來源:網(wǎng)絡(luò)整理 瀏覽:
主機(jī)規(guī)劃主機(jī)名稱操作系統(tǒng)版本內(nèi)網(wǎng)IP外網(wǎng)IP(模擬)安裝軟件ansi-manager CentOS7.5 172.16.1.180 10.0

主機(jī)規(guī)劃

主機(jī)名稱操作系統(tǒng)版本內(nèi)網(wǎng)IP外網(wǎng)IP(模擬)安裝軟件

ansi-manager CentOS7.5 172.16.1.180 10.0.0.180

ansibleansi-haproxy01 CentOS7.5 172.16.1.181 10.0.0.181

ansi-haproxy02 CentOS7.5 172.16.1.182 10.0.0.182

ansi-web01 CentOS7.5 172.16.1.183 10.0.0.183

ansi-web02 CentOS7.5 172.16.1.184 10.0.0.184

ansi-web03 CentOS7.5 172.16.1.185 10.0.0.185

在實(shí)際使用中并不需要對(duì)ansible配置進(jìn)行修改,或者說只有需要的時(shí)候才修改ansible配置。


添加用戶賬號(hào)

說明:

1、 運(yùn)維人員使用的登錄賬號(hào);

2、 所有的業(yè)務(wù)都放在 /app/ 下「yun用戶的家目錄」,避免業(yè)務(wù)數(shù)據(jù)亂放;

3、 該用戶也被 ansible 使用,因?yàn)閹缀跛械纳a(chǎn)環(huán)境都是禁止 root 遠(yuǎn)程登錄的(因此該 yun 用戶也進(jìn)行了 sudo 提權(quán))。

1 # 使用一個(gè)專門的用戶,避免直接使用root用戶
2 # 添加用戶、指定家目錄并指定用戶密碼
3 # sudo提權(quán)
4 # 讓其它普通用戶可以進(jìn)入該目錄查看信息
5 useradd -u 1050 -d /app yun && echo '123456' | /usr/bin/passwd --stdin yun
6 echo "yun ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
7 chmod 755 /app/
Ansible 部署流程添加 epel 源「如果沒有的話」

添加阿里云 epel 源

https://opsx.alibaba.com/mirror
Ansible-安裝配置

Ansible 安裝與版本信息查看
 1 [root@ansi-manager ~]# yum install -y ansible  
2 [root@ansi-manager ~]# whereis ansible # ansible 位置信息
3 ansible: /usr/bin/ansible /etc/ansible /usr/share/ansible /usr/share/man/man1/ansible.1.gz
4 [root@ansi-manager ~]# ansible --version # 版本信息查看
5 ansible 2.8.1 # ansible 版本
6 config file = /etc/ansible/ansible.cfg # 使用的配置文件
7 configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] # 模塊查找路徑
8 ansible python module location = /usr/lib/python2.7/site-packages/ansible # ansible Python 模塊位置,使用 Python 2.7
9 executable location = /bin/ansible # ansible 執(zhí)行文件的位置
10 python version = 2.7.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] # Python 版本信息
11 [yun@ansi-manager ~]$ ll /usr/bin/ansible /bin/ansible # ansible 命令位置
12 lrwxrwxrwx 1 root root 20 Jun 24 14:14 /bin/ansible -> /usr/bin/ansible-2.7
13 lrwxrwxrwx 1 root root 20 Jun 24 14:14 /usr/bin/ansible -> /usr/bin/ansible-2.7
Ansible 配置文件講解Ansible配置文件查找順序

ansible 將從多個(gè)地方查找配置文件,順序如下:

1、從環(huán)境變量 ANSIBLE_CONFIG 中查找,如果該環(huán)境變量有值的話;

2、當(dāng)前目錄的 ansible.cfg 文件;「每個(gè)項(xiàng)目都可以有一個(gè)該配置文件,這樣可以更好的管理項(xiàng)目,移植時(shí)也更方便。」

3、當(dāng)前用戶家目錄的 .ansible.cfg 文件;

4、/etc/ansible/ansible.cfg 文件。

可以使用 ansible –version 命令查看使用的配置文件。

在 /etc/ansible/ansible.cfg 配置文件中有該說明
Ansible 部分配置文件講解

實(shí)際生產(chǎn)中可以無需做任何修改。

 1 [yun@ansi-manager ansible]$ pwd
2 /etc/ansible
3 [yun@ansi-manager ansible]$ vim ansible.cfg
4 #inventory = /etc/ansible/hosts # 受控端主機(jī)資源清單
5 #library = /usr/share/my_modules/ # 所需依賴庫路徑
6 #remote_tmp = ~/.ansible/tmp # 遠(yuǎn)端機(jī)器,臨時(shí)文件存放位置
7 #local_tmp = ~/.ansible/tmp # 本機(jī)臨時(shí)文件存放位置
8 #forks = 5 # 默認(rèn)并發(fā)數(shù)
9 #poll_interval = 15 # 默認(rèn)輪詢時(shí)間間隔(單位秒)
10 #sudo_user = root # 默認(rèn)sudo后的用戶
11 #ask_sudo_pass = True # 使用sudo,是否需要輸入密碼
12 #ask_pass = True # 是否需要輸入密碼
13 #transport = smart # 傳輸方式
14 #remote_port = 22 # 默認(rèn)遠(yuǎn)程主機(jī)的端口號(hào)
15 #module_lang = C # 模塊和系統(tǒng)之間通信的語言
16 #module_set_locale = False
17 ………………
18 # uncomment this to disable SSH key host checking 取消注釋以禁用SSH key主機(jī)檢查 【默認(rèn)是注釋掉的,要檢查主機(jī)指紋】
19 host_key_checking = False # 解開注釋,即跳過檢查主機(jī)指紋 【只有 root 用戶執(zhí)行時(shí)才有該取消指紋檢測(cè)的權(quán)限】
20 ………………
21 # logging is off by default unless this path is defined
22 # if so defined, consider logrotate
23 #log_path = /var/log/ansible.log # 開啟ansible日志
24 ………………
25 [privilege_escalation] # 普通用戶提權(quán)配置「使用地方:普通用戶遠(yuǎn)程提權(quán)使用」
26 #become=True
27 #become_method=sudo
28 #become_user=root
29 #become_ask_pass=False

上述的 [privilege_escalation] 配置,可在 ansible -h 中查看如何使用。如下:

 1 [yun@ansi-manager ~]$ ansible -h 
2 ………………
3 Privilege Escalation Options: # 權(quán)限提升選項(xiàng)
4 control how and which user you become as on target hosts
5
6 -b, --become run operations with become (does not imply password
7 prompting)
8 --become-method=BECOME_METHOD
9 privilege escalation method to use (default=sudo), use
10 `ansible-doc -t become -l` to list valid choices.
11 --become-user=BECOME_USER
12 run operations as this user (default=root)
13 -K, --ask-become-pass
14 ask for privilege escalation password
15 ………………


Ansible-安裝配置

推薦內(nèi)容