中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

做網(wǎng)站實(shí)名認(rèn)證總是失敗怎么回事我們seo

做網(wǎng)站實(shí)名認(rèn)證總是失敗怎么回事,我們seo,建設(shè)部網(wǎng)站阮建昌公示,廣州一起做網(wǎng)店官網(wǎng)app目錄 一、Ansible 的腳本 playbook 劇本1.1playbooks的組成 二、劇本編寫實(shí)驗(yàn)2.1定義、引用變量2.2使用遠(yuǎn)程主機(jī)sudo切換用戶2.3whenn條件判斷2.4迭代 三、Templates 模板四、Tags模板 一、Ansible 的腳本 playbook 劇本 1.1playbooks的組成 (1)Tasks&…

目錄

  • 一、Ansible 的腳本 playbook 劇本
    • 1.1playbooks的組成
  • 二、劇本編寫實(shí)驗(yàn)
    • 2.1定義、引用變量
    • 2.2使用遠(yuǎn)程主機(jī)sudo切換用戶
    • 2.3whenn條件判斷
    • 2.4迭代
  • 三、Templates 模板
  • 四、Tags模板

一、Ansible 的腳本 playbook 劇本

1.1playbooks的組成

(1)Tasks:任務(wù),即通過 task 調(diào)用 ansible 的模板將多個(gè)操作組織在一個(gè) playbook 中運(yùn)行
(2)Variables:變量
(3)Templates:模板
(4)Handlers:處理器,當(dāng)changed狀態(tài)條件滿足時(shí),(notify)觸發(fā)執(zhí)行的操作
(5)Roles:角色

二、劇本編寫實(shí)驗(yàn)

vim test1.yaml
---     #yaml文件以---開頭,以表明這是一個(gè)yaml文件,可省略
- name: first play     #定義一個(gè)play的名稱,可省略gather_facts: false    #設(shè)置不進(jìn)行facts信息收集,這可以加快執(zhí)行速度,可省略hosts: webservers    #指定要執(zhí)行任務(wù)的被管理主機(jī)組,如多個(gè)主機(jī)組用冒號分隔remote_user: root    #指定被管理主機(jī)上執(zhí)行任務(wù)的用戶tasks:     #定義任務(wù)列表,任務(wù)列表中的各任務(wù)按次序逐個(gè)在hosts中指定的主機(jī)上執(zhí)行- name: test connection    #自定義任務(wù)名稱ping:     #使用 module: [options] 格式來定義一個(gè)任務(wù)- name: disable selinuxcommand: '/sbin/setenforce 0'    #command模塊和shell模塊無需使用key=value格式ignore_errors: True     #如執(zhí)行命令的返回值不為0,就會報(bào)錯(cuò),tasks停止,可使用ignore_errors忽略失敗的任務(wù)- name: disable firewalldservice: name=firewalld state=stopped    #使用 module: options 格式來定義任務(wù),option使用key=value格式- name: install httpdyum: name=httpd state=latest- name: install configuration file for httpdcopy: src=/opt/httpd.conf dest=/etc/httpd/conf/httpd.conf    #這里需要一個(gè)事先準(zhǔn)備好的/opt/httpd.conf文件notify: "restart httpd"    #如以上操作后為changed的狀態(tài)時(shí),會通過notify指定的名稱觸發(fā)對應(yīng)名稱的handlers操作- name: start httpd serviceservice: enabled=true name=httpd state=startedhandlers:     #handlers中定義的就是任務(wù),此處handlers中的任務(wù)使用的是service模塊- name: restart httpd    #notify和handlers中任務(wù)的名稱必須一致service: name=httpd state=restarted
##Ansible在執(zhí)行完某個(gè)任務(wù)之后并不會立即去執(zhí)行對應(yīng)的handler,而是在當(dāng)前play中所有普通任務(wù)都執(zhí)行完后再去執(zhí)行handler,這樣的好處是可以多次觸發(fā)notify,但最后只執(zhí)行一次對應(yīng)的handler,從而避免多次重啟。

在這里插入圖片描述
運(yùn)行playbook

ansible-playbook test1.yaml
//補(bǔ)充參數(shù):
-k(–ask-pass):用來交互輸入ssh密碼
-K(-ask-become-pass):用來交互輸入sudo密碼
-u:指定用戶
ansible-playbook test1.yaml --syntax-check    #檢查yaml文件的語法是否正確
ansible-playbook test1.yaml --list-task       #檢查tasks任務(wù)
ansible-playbook test1.yaml --list-hosts      #檢查生效的主機(jī)
ansible-playbook test1.yaml --start-at-task='install httpd'     #指定從某個(gè)task開始運(yùn)行

在這里插入圖片描述
在這里插入圖片描述

2.1定義、引用變量

- name: second playhosts: dbserversremote_user: rootvars:                 #定義變量- groupname: mysql   #格式為 key: value- username: nginxtasks:- name: create groupgroup: name={{groupname}} system=yes gid=306    #使用 {{key}} 引用變量的值- name: create useruser: name={{username}} uid=306 group={{groupname}} - name: copy filecopy: content="{{ansible_default_ipv4}}" dest=/opt/vars.txt    #在setup模塊中可以獲取facts變量信息ansible-playbook test1.yaml -e "username=nginx"     #在命令行里定義變量

在這里插入圖片描述
在這里插入圖片描述

2.2使用遠(yuǎn)程主機(jī)sudo切換用戶

- hosts: dbserversremote_user: zhangsan            become: yes	                 #2.6版本以后的參數(shù),之前是sudo,意思為切換用戶運(yùn)行become_user: root              #指定sudo用戶為root
執(zhí)行playbook時(shí):ansible-playbook test1.yml -k -K 

2.3whenn條件判斷

- name: three playhosts: allremote_user: roottasks:- name: create filefile: path=/opt/abc.txt state=touchwhen: ansible_default_ipv4.address=="192.168.243.103" #通過facts收集的信息過濾出匹配的主機(jī),when中的變量名字,不需要手動(dòng)加{{}}或 when: inventory_hostname == "<主機(jī)名>"ansible-playbook test2.yaml

在這里插入圖片描述

2.4迭代

  • Ansible提供了很多種循環(huán)結(jié)構(gòu),一般都命名為with_items,作用等同于 loop 循環(huán)。
- name: play1hosts: dbserversgather_facts: falsetasks: - name: create filefile:path: "{{item}}"state: touchwith_items: [ /opt/a, /opt/b, /opt/c, /opt/d ]- name: play2hosts: dbserversgather_facts: false		vars:test:- /tmp/test1- /tmp/test2- /tmp/test3- /tmp/test4tasks: - name: create directoriesfile:path: "{{item}}"state: directorywith_items: "{{test}}"- name: play3hosts: dbserversgather_facts: falsetasks:- name: add usersuser: name={{item.name}} state=present groups={{item.groups}}with_items:- name: test1groups: wheel- name: test2groups: root
或with_items:- {name: 'test1', groups: 'wheel'}- {name: 'test2', groups: 'root'}ansible-playbook test3.yaml

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

三、Templates 模板

  • Jinja是基于Python的模板引擎。Template類是Jinja的一個(gè)重要組件,可以看作是一個(gè)編譯過的模板文件,用來產(chǎn)生目標(biāo)文本,傳遞Python的變量給模板去替換模板中的標(biāo)記。

1.先準(zhǔn)備一個(gè)以 .j2 為后綴的 template 模板文件,設(shè)置引用的變量

cp /etc/httpd/conf/httpd.conf /opt/httpd.conf.j2vim /opt/httpd.conf.j2
Listen {{http_port}}				#42行,修改
ServerName {{server_name}}			#95行,修改
DocumentRoot "{{root_dir}}"          #119行,修改

在這里插入圖片描述

2.修改主機(jī)清單文件,使用主機(jī)變量定義一個(gè)變量名相同,而值不同的變量

vim /etc/ansible/hosts       
[webservers]
192.168.80.11 http_port=192.168.80.11:80 server_name=www.accp.com:80 root_dir=/etc/httpd/htdocs[dbservers]
192.168.80.12 http_port=192.168.80.12:80 server_name=www.benet.com:80 root_dir=/etc/httpd/htdocs

在這里插入圖片描述
3.編寫 playbook

vim apache.yaml
---
- hosts: allremote_user: rootvars:- package: httpd- service: httpdtasks:- name: install httpd packageyum: name={{package}} state=latest- name: install configure filetemplate: src=/opt/httpd.conf.j2 dest=/etc/httpd/conf/httpd.conf     #使用template模板notify:- restart httpd- name: create root dirfile: path=/etc/httpd/htdocs state=directory- name: start httpd serverservice: name={{service}} enabled=true state=startedhandlers:- name: restart httpdservice: name={{service}} state=restartedansible-playbook apache.yaml

在這里插入圖片描述
在這里插入圖片描述

四、Tags模板

  • 可以在一個(gè)playbook中為某個(gè)或某些任務(wù)定義“標(biāo)簽”,在執(zhí)行此playbook時(shí)通過ansible-playbook命令使用–tags選項(xiàng)能實(shí)現(xiàn)僅運(yùn)行指定的tasks。
    playbook還提供了一個(gè)特殊的tags為always。作用就是當(dāng)使用always作為tags的task時(shí),無論執(zhí)行哪一個(gè)tags時(shí),定義有always的tags都會執(zhí)行。
- name: serve playremote_user: roothosts: webserverstasks:- name: touch ddd,txtfile: path=/opt/ddd.txt state=touchtags:  #標(biāo)簽為ddd當(dāng)命令tags標(biāo)簽為ddd,或者沒有標(biāo)簽才執(zhí)行- ddd- name: touch 123.txtfile: path=/opt/123.txt state=touchtags:- always #alwats表示都執(zhí)行- name: touch abc.txtfile: path=/opt/abc.txt state=touchtags:- aaa #同上

在這里插入圖片描述

http://www.risenshineclean.com/news/2690.html

相關(guān)文章:

  • 北京網(wǎng)站設(shè)計(jì)公司youx成都柚米科技15寧波seo外包推廣排名
  • 門戶網(wǎng)站廣告是什么專門做排名的軟件
  • nba網(wǎng)站建設(shè)營銷技巧五步推銷法
  • 做資源網(wǎng)站需要什么seo優(yōu)化關(guān)鍵詞0
  • 深圳建工是國企還是私企武漢seo公司哪家好
  • 尋找做網(wǎng)站的廣告網(wǎng)站策劃方案
  • 幫你省網(wǎng)站怎么做優(yōu)秀的軟文廣告案例
  • 有贊商城官網(wǎng)登錄旺道seo網(wǎng)站優(yōu)化大師
  • 常平網(wǎng)站仿做百度手機(jī)衛(wèi)士
  • 網(wǎng)站優(yōu)化網(wǎng)千鋒教育培訓(xùn)機(jī)構(gòu)怎么樣
  • 做色情網(wǎng)站多久會被抓網(wǎng)絡(luò)營銷服務(wù)
  • 泉州市住房和城鄉(xiāng)建設(shè)部網(wǎng)站南寧網(wǎng)站優(yōu)化公司電話
  • 自制游戲軟件seo怎樣
  • 網(wǎng)站做維恩圖公司網(wǎng)站制作教程
  • 合肥軟件外包公司關(guān)鍵詞優(yōu)化排名查詢
  • 南寧微信網(wǎng)站制作周口網(wǎng)絡(luò)推廣哪家好
  • 做網(wǎng)站優(yōu)化要多少錢廣州網(wǎng)絡(luò)seo優(yōu)化
  • 網(wǎng)站名字大全有哪些鄭州網(wǎng)站優(yōu)化外包
  • 網(wǎng)站建設(shè)微信商城多少錢病毒式營銷案例
  • wordpress摘要添加省略號鄂州網(wǎng)站seo
  • 網(wǎng)站的收費(fèi)標(biāo)準(zhǔn)品牌運(yùn)營策劃
  • 建設(shè)網(wǎng)站怎么掙錢廣東網(wǎng)約車漲價(jià)
  • 山東自助seo建站商丘seo外包
  • 卡地亞手表官方網(wǎng)站查詢上海seo優(yōu)化服務(wù)公司
  • 展示型企業(yè)網(wǎng)站有哪些推廣普通話黑板報(bào)
  • 外包做網(wǎng)站要十幾萬泉州排名推廣
  • 為什么做網(wǎng)站推廣站長域名查詢工具
  • 北京網(wǎng)站手機(jī)站建設(shè)公司電話號碼上海牛巨微seo
  • 開源網(wǎng)站建設(shè)網(wǎng)站alexa排名
  • 阿里云網(wǎng)站怎么備案域名網(wǎng)絡(luò)營銷戰(zhàn)略