zoukankan      html  css  js  c++  java
  • roles

      

    nginx 官方下载

    [root@ansible roles]# tree yngx
    yngx
    ├── defaults
    ├── files
    │   ├── blog.conf
    │   ├── edusoho-8.2.17.tar.gz
    │   ├── nginx.repo
    │   ├── WeCenter_v3.1.9.zip
    │   └── wordpress-5.0.2-zh_CN.tar.gz
    ├── handlers
    │   └── main.yml
    ├── tasks
    │   ├── load.yml
    │   ├── main.yml
    │   └── main.yml.bak
    ├── template
    └── vars
        └── main.yml
    变量
    [root@ansible yngx]# cat vars/main.yml user: www group: www dir: /code/

    官方yum源
    [root@ansible files]# cat nginx.repo 
    [nginx]
    name=nginx repo
    baseurl=http://nginx.org/packages/centos/7/$basearch/
    gpgcheck=0
    enabled=1

    任务剧本
    [root@ansible yngx]# cat tasks/main.yml - name: cp ngxconf copy: src=blog.conf dest=/etc/nginx/conf.d notify: restart ngx tags: restart ngx - name: cp repo copy: src=nginx.repo dest=/etc/yum.repos.d/ - name: ingx yum: name=nginx state=installed - name: chang ngx user shell: sed -i '/^user/c user www;' /etc/nginx/nginx.conf - include: load.yml tags: load - name: start ngx service: name=nginx state=started enabled=yes
    下载产品

    [root@ansible yngx]# cat tasks/load.yml - name: load pag get_url: url={{ item }} dest=/code/ with_items: - https://cn.wordpress.org/wordpress-5.0.2-zh_CN.tar.gz - http://ahdx.down.chinaz.com/201605/WeCenter_v3.1.9.zip - http://download.edusoho.com/edusoho-8.2.17.tar.gz 解压 - name: tar 1 unarchive: src=files/{{ item }} dest=/code/ owner={{ user }} group={{ group }} copy=yes with_items: - wordpress-5.0.2-zh_CN.tar.gz - edusoho-8.2.17.tar.gz #- WeCenter_v3.1.9.zip tags: load

    nginx配置文件
    [root@ansible files]# cat blog.conf server { listen 80; server_name blog.oldboy.com; root /code/wordpress; index index.php index.html; location ~ .php$ { root /code/wordpress; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }

    安装php7.2剧本

    [root@ansible roles]# tree yphp
    yphp
    ├── files
    ├── handlers
    │   └── main.yml
    ├── tasks
    │   └── main.yml
    └── vars
    [root@ansible tasks]# cat main.yml 
    - name: install three epel 1 yum: name=https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm state=installed - name: install three epel 2 yum: name=https://mirror.webtatic.com/yum/el7/webtatic-release.rpm state=installed - name: chang www 1 shell: sed -i '/^user/c user = www' /etc/php-fpm.d/www.conf - name: chang www shell: sed -i '/^group/c group = www' /etc/php-fpm.d/www.conf - name: del pag yum: name={{ item }} state=absent with_items: - php-mysql-5.4 - php - php-fpm - php-common - name: insatll php yum: name={{ item }} state=latest with_items: - 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 service: name=php-fpm state=started enabled=yes

    用户目录,基础任务

    [root@ansible roles]# tree base/
    base/
    ├── defaults
    ├── tasks
    │   ├── dir.yml
    │   ├── main.yml
    │   └── user.yml
    └── vars
    └── main.yml


    [root@ansible base]# cat vars/main.yml user: www group: www appdir: /code

    [root@ansible tasks]# cat dir.yml
    - name: create {{ dir }}
      file: path=/code state=directory

    [root@ansible tasks]# cat dir.yml
    - name: create {{ dir }}
    file: path=/code state=directory
    [root@ansible tasks]# cat user.yml
    - name: create group
      group: name={{ group }} gid=777 system=yes
    - name: create user
      user: name={{ user }} uid=777 system=yes group={{ group }}

    [root@ansible tasks]# cat main.yml
    - include: dir.yml
    - include: user.yml

    命令行可执行 剧本里定义的 tags

    ansible-playbook -C -t cp lnmp.yml

  • 相关阅读:
    Neko's loop HDU-6444(网络赛1007)
    Parameters
    SETLOCAL
    RD / RMDIR Command
    devenv 命令用法
    Cannot determine the location of the VS Common Tools folder.
    'DEVENV' is not recognized as an internal or external command,
    How to change Visual Studio default environment setting
    error signing assembly unknown error
    What is the Xcopy Command?:
  • 原文地址:https://www.cnblogs.com/john5yang/p/10177223.html
Copyright © 2011-2022 走看看