国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

ansible-playbook roles編寫lnmp劇本

這篇具有很好參考價值的文章主要介紹了ansible-playbook roles編寫lnmp劇本。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

目錄

集中式編寫lnmp劇本

執(zhí)行

分布式編寫lnmp劇本

一定要設置ssh免交互

?nginx

mysql

php

?執(zhí)行文章來源地址http://www.zghlxwxcb.cn/news/detail-622490.html


集中式編寫lnmp劇本

vim /etc/ansible/lnmp.yml
- name: lnmp play
  hosts: dbservers
  remote_user: root
 
  tasks:
  - name: perpare condifure
    copy: src=/etc/yum.repos.d/nginx.repo dest=/etc/yum.repos.d/nginx.repo
  - name: install nginx
    yum: name=nginx state=latest
  - name: start nginx
    service: name=nginx state=started enabled=yes
    
  - name: install mysql
    yum: name=mysql57-community-release-el7-10.noarch.rpm state=latest
  - name: modify file
    replace:
      path: /etc/yum.repos.d/mysql-community.repo
      regexp: 'gpgcheck=1'
      replace: 'gpgcheck=0'
  - name: install mysql-community-server
    yum: name=mysql-community-server state=latest
  - name: start mysql
    service: name=mysqld state=started enabled=yes
 
  - name: add yum file
    command: 'wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm -P /etc/yum.repos.d' - name: rpm epel
    command: 'rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm'
  - name: rpm el7
    command: 'rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm'
  - name: install php
    command: 'yum install -y php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm php72w-mysqlnd php72w-opcache'
  - name: start php-fpm
    service: name=php-fpm state=started  enabled=yes
  - name: copy configure
    copy: src=/usr/local/nginx/conf/nginx.conf dest=/etc/nginx/conf.d/default.conf
  - name: restart nginx
    service: name=nginx state=started enabled=yes

執(zhí)行

ansible-playbook lnmp.yml

分布式編寫lnmp劇本

一定要設置ssh免交互

ssh-keygen -t rsa
sshpass -p’zxr123‘ ssh-copy-id? 192.168.110.60?
mkdir /etc/ansible/roles/httpd/{files,templates,tasks,handlers,vars,defaults,meta} -p
mkdir /etc/ansible/roles/mysql/{files,templates,tasks,handlers,vars,defaults,meta} -p
mkdir /etc/ansible/roles/php/{files,templates,tasks,handlers,vars,defaults,meta} -p
 
touch /etc/ansible/roles/httpd/{defaults,vars,tasks,meta,handlers}/main.yml
touch /etc/ansible/roles/mysql/{defaults,vars,tasks,meta,handlers}/main.yml
touch /etc/ansible/roles/php/{defaults,vars,tasks,meta,handlers}/main.yml

?nginx

cd /etc/ansible/roles/nginx/files

index.php  nginx.repo
?vim /etc/ansible/roles/nginx/files/index.php
<?php
phpinfo();
?>

?vim /etc//ansible/roles/nginx/files/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

?vim?/etc/ansible/roles/nginx/main.yml
- include: "init.yml"

- name: copy nginx repo
  copy: src=nginx.repo dest=/etc/yum.repos.d/
- name: install nginx
  yum: name=nginx state=latest
- name: copy index.php
  copy: src=index.php dest=/var/www/html
- name: transmit nginx configuration
  template: src=default.conf.j2 dest=/etc/nginx/conf.d/default.conf
- name: start nginx
  service: name=nginx state=started enabled=yes

vim /etc/ansible/roles/index.php
- name: stop firewalld
  service: name=firewalld state=stopped enabled=no
- name: stop selinux
  command: 'setenforce 0'

vim /etc/ansible/roles/nginx/template/default.conf.j2
server {
    listen       80;
    server_name  localhost;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /var/www/html;
        index  index.php index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           html;
        fastcgi_pass   192.168.110.60:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

mysql

vim /etc/ansible/roles/mysql/tasks/init.yml
- name: stop firewalld
  service: name=firewalld state=stopped enabled=no
- name: stop selinux
  command: 'setenforce 0'

vim?/etc/ansible/roles/mysql/main.yml
- include: "init.yml"

- name: remove mariadb
  shell: 'yum remove mariadb* -y'
- name: wget
  shell: 'wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm -P /etc/yum.repos.d'
- name: install mysql57-community-release-el7-10.noarch.rpm
  yum: name=epel-release
- name: sed
  replace: path=/etc/yum.repos.d/mysql-community.repo regexp="gpgcheck=1" replace="gpgcheck=0"
- name: install mysql-community-server
  yum: name=mysql-community-server
- name: start mysql
  service: name=mysqld.service state=started
- name: passd
  shell: passd=$(grep "password" /var/log/mysqld.log | awk 'NR==1 {print $NF}')
- name: mysql 1
  shell: mysql -uroot -p'passd' --connect-expired-password -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'ZXRabc@123';"
  ignore_errors: true
- name: mysql 2
  shell: mysql -uroot -pZXRabc@123 -e "grant all privileges on *.* to root@'%' identified by 'ZXRabc@123' with grant option;"
  ignore_errors: true

php

vim /etc/ansible/roles/php/tasks/init.yml
- name: stop firewalld
  service: name=firewalld state=stopped enabled=no
- name: stop selinux
  command: 'setenforce 0'

vim /etc/ansible/rolesphp/tasks/main.yml
- include: "init.yml"

- name: install yum repo
  shell: "rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm"
  ignore_errors: true
- name: install php
  command: 'yum install -y php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-pdo php72w-xml php72w-fpm php72w-mysqlnd php72w-opcache'
- name: add user
  user:
    name: php
    shell: /sbin/nologin
    system: yes
- name: copy php.ini
  copy: src=php.ini dest=/etc/php.ini
- name: copy www.conf
  copy: src=www.conf dest=/etc/php-fpm.d/www.conf
- name: copy index.php
  copy: src=index.php dest=/var/www/html
- name: start php-fpm
  service: name=php-fpm state=started

?執(zhí)行

vim /etc/ansible/lnmp.yml
- name: nginx play
  hosts: webservers
  remote_user: root
  roles:
    - nginx

- name: mysql play
  hosts: dbservers
  remote_user: root
  roles:
    - mysql

- name: php play
  hosts: phpservers
  remote_user: root
  roles:
    - php
ansible-playbook lnmp.yml

到了這里,關于ansible-playbook roles編寫lnmp劇本的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!

本文來自互聯(lián)網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • 【playbook】Ansible的腳本----playbook劇本

    【playbook】Ansible的腳本----playbook劇本

    (1) Tasks :任務,即 通過task調用ansible的模板將多個操作組織在一個playbook中運行 (2) Variables :變量 (3) Templates :模板 (4) Handlers :處理器, 當changed狀態(tài)條件滿足時,(notify)觸發(fā)執(zhí)行的操作 (5) Roles :角色 在ansible服務器主機,給遠程被管理主機制作安裝Apach

    2024年02月14日
    瀏覽(14)
  • ansible的playbook劇本

    ansible的playbook劇本

    (1)Tasks:任務,即通過 task 調用 ansible 的模塊將多個操作組織在一個 playbook 中運行 (2)Variables:變量 (3)Templates:模板 (4)Handlers:處理器,當changed狀態(tài)條件滿足時,(notify)觸發(fā)執(zhí)行的操作 (5)Roles:角色 ==Ansible在執(zhí)行完某個任務之后并不會立即去執(zhí)行對應的han

    2024年02月12日
    瀏覽(19)
  • Ansible playbook ----- 劇本

    Ansible playbook ----- 劇本

    playbooks 本身由以下各部分組成 (1)Tasks:任務,即通過 task 調用 ansible 的模板將多個操作組織在一個 playbook 中運行 (2)Variables:變量 (3)Templates:模板 (4)Handlers:處理器,當changed狀態(tài)條件滿足時,(notify)觸發(fā)執(zhí)行的操作 (5)Roles:角色 //示例: vim test1.yaml --- ? ?

    2024年02月10日
    瀏覽(25)
  • Ansible之playbooks劇本

    Ansible之playbooks劇本

    (1)playbooks是ansible用于配置,部署,和管理被控節(jié)點的劇本。 (2)通過playbooks的詳細描述,執(zhí)行其中的tasks,可以讓遠端主機達到預期的狀態(tài)。playbooks是由一個或多個”play”組成的列表。 當對一臺機器做環(huán)境初始化的時候往往需要不止做一件事情,使用playbooks。 (3)通過

    2024年02月09日
    瀏覽(17)
  • Ansible之playbook劇本

    Ansible之playbook劇本

    playbook 是 ansible 用于配置,部署,和管理被控節(jié)點的劇本。通過 playbook 的詳細描述,執(zhí)行其中的一系列 tasks ,可以讓遠端主機達到預期的狀態(tài)。playbook 就像 Ansible 控制器給被控節(jié)點列出的的一系列 to-do-list ,而被控節(jié)點必須要完成。也可以這么理解,playbook 字面意思,即劇

    2024年02月09日
    瀏覽(16)
  • Ansible劇本--Playbook

    在ansible中,類似“腳本”的文件被稱作“劇本”,英文稱為playbook,用于配置、部署和管理被控節(jié)點 只需要把模塊按照順序編排在playbook劇本中,ansible就會按照劇本一步一步的執(zhí)行,最終達到我們需要實現(xiàn)的效果 playbook是由一個或多個\\\'play\\\'組成的列表,當我們在工作中需要不

    2024年01月19日
    瀏覽(17)
  • Ansible 的腳本-playbook 劇本

    1.playbooks 本身由以下各部分組成 (1)Tasks:任務,即通過 task 調用 ansible 的模板將多個操作組織在一個 playbook 中運行 (2)Variables:變量 (3)Templates:模板 (4)Handlers:處理器,當changed狀態(tài)條件滿足時,(notify)觸發(fā)執(zhí)行的操作 (5)Roles:角色 2.示例 3.定義、引用變量

    2024年02月06日
    瀏覽(18)
  • 【Ansible 的腳本 --- playbook 劇本】

    【Ansible 的腳本 --- playbook 劇本】

    playbooks 本身由以下各部分組成 將yum安裝的nginx里面的配置文件進行修改,后傳輸?shù)綄倪h程主機 解壓wordpress壓縮文件,放入到對應的html網頁目錄底下 進行傳輸?shù)竭h程主機里的網頁頁面目錄上 使用瀏覽器進行訪問測試

    2024年02月14日
    瀏覽(18)
  • Ansible的腳本-playbook 劇本

    ? ?1.playbook介紹 ? ? ? ? playbook是ansible用于配置,部署,和管理被控節(jié)點的劇本。通過playbook的詳細描述,執(zhí)行其中的tasks,可以讓遠端主機達到預期的狀態(tài)。playbook是由一個或多個”play”組成的列表。 當對一臺機器做環(huán)境初始化的時候往往需要不止做一件事情,這時使用

    2024年02月02日
    瀏覽(22)
  • Ansible Playbook劇本配置文件

    Ansible Playbook劇本配置文件

    目錄 一、執(zhí)行文件 修改hosts文件 Playbook的核心元素包含: 用法 實驗案例 1.語法檢查 2.預測試 3.列出主機 4.列出任務 5.列出標簽 6.進行測試 7.測試查看 二、觸發(fā)器 handlers觸發(fā)器的實驗實例如下 預執(zhí)行 執(zhí)行 查看結果 三、角色 /etc/ansible/roles/為角色集合,該目錄下有自定義的各

    2024年02月16日
    瀏覽(20)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包