本文共 3174 字,大约阅读时间需要 10 分钟。
- hosts: docker remote_user: root vars: nginx80: /usr/local/nginx/conf/vhost nginx14: https://nginx.org/download/nginx-1.14.2.tar.gz tasks: - command: ls nginx-1.14.2.tar.gz register: result - command: ls /usr/local/nginx/conf/vhost register: han ignore_errors: true - name: wget nginx_url14.2 shell: wget https://nginx.org/download/nginx-1.14.2.tar.gz when: result|failed - name: mkdir nginx conf shell: mkdir -p { { nginx80 }} when: han|failed - name: touch nginx config file: path={ { nginx80 }}/{ { item }} mode=0644 state=touch with_items: - nginx80.conf - nginx8080.conf
vars: - nginx80: /usr/local/nginx/conf/vhost - nginx14: https://nginx.org/download/nginx-1.14.2.tar.gz
- hosts: docker remote_user: root vars: nginx: nginx80: /usr/local/nginx/conf/vhost1 nginx14: https://nginx.org/download/nginx-1.14.2.tar.gz wwwuser: nginxuser: www tasks: - name: conf nginx shell: wget { {nginx.nginx14 }} - name: mkdir nginx80 shell: mkdir -p { {nginx.nginx80}} - name: touch nginx config file: path={ { nginx.nginx80 }}/{ { item }} mode=0644 state=touch with_items: - nginx_var.conf - name: gourp www group: name={ { wwwuser['nginxuser']}} gid=3001 - name: useradd nginx user user: name={ { wwwuser.nginxuser }} group=www uid=3001 shell=/sbin/nologin
A: { { nginx.nginx80 }} B: { wwwuser['nginxuser']}}
vars_files: - /data/sh/vars_nginx.yml - /data/sh/vars_nginx_user.yml
- hosts: docker remote_user: root vars_files: - /data/sh/vars_nginx.yml - /data/sh/vars_nginx_user.yml tasks: - name: conf nginx shell: wget { {nginx.nginx14 }} - name: mkdir nginx80 shell: mkdir -p { {nginx.nginx80}} - name: touch nginx config file: path={ { nginx.nginx80 }}/{ { item }} mode=0644 state=touch with_items: - nginx_var.conf - name: gourp www group: name={ { wwwuser['nginxuser']}} gid=3001 - name: useradd nginx user user: name={ { wwwuser.nginxuser }} group=www uid=3001 shell=/sbin/nologin
- hosts: docker remote_user: root vars: nginx: nginx80: /usr/local/nginx/conf/vhost1 nginx14: https://nginx.org/download/nginx-1.14.2.tar.gz wwwuser: nginxuser: www vars_prompt: - name: "user_name" prompt: "Enter input name" private: no - name: "user_Password" prompt: "Enter input password(md5之后的加密串)" encrypt: "sha512_crypt" #给与哈希加密 confirm实现密码确认功能 开启是需要数据两次密码 confirm: yes tasks: - name: create user user: name="{ {user_name}}" uid=3004 group=root password="{ {user_Password}}" shell=/bin/bash home=/home/{ {user_name}}
转载于:https://blog.51cto.com/9025736/2330474