A, ansible - roles use
ansible Before explaining the use of the playbook, then introduce the use of roles (and messy screenplay is too much, not eleven write, please forgive me)
1.Nginx installation information:
nginx_user: www #nginx user nginx_port: 80 #nginx listening port nginx_web_dir: / the Data / Webroot / nginx #nginx directory nginx_version: 1.17 . 2 #nginx version pcre_version: 8.33 #pcre version pretended_name: Tengine # For security reasons, the nginx name to tengine pretended_version: 1.17 . 0 # hidden version, another version tengine
2.PHP installation information:
php_user: www #php fpm start the user mode php_port: 9000 #php FPM using tcp port php_dir: / usr / local #php installation directory php_version: 7.2 . 21 is #php version mysql_basedir: / Data / MySQL / #mysql the basedir the catalog
3.MySQL installation information:
mysql_basedir: / Data / MySQL / the basedir source directory # mysql_datadir: / Data / MySQL / DATADIR data directory # mysql_user: mysql #mysql User mysql_database_user: root # Database User mysql_passwd: ' 123456 ' # database password MYSQL_PORT: 3306 #mysql listening port mysql_sock : / Data / MySQL / DATADIR / mysql.sock #mysql of our sock mysql_charset: character set UTF8 #mysql mysql_collation: utf8_general_ci #mysql Sort mysql_version: mysql- 5.6 . 45 .tar.gz version #mysql
4.playbook installation structure:
* * php mysql tree INX * nginx_delete ├── files ├── handlers ├── meta │ └── main.yml ├── Tasks │ ├── delete.yml │ └── main.yml ├── templates └ ── VARs └── main.yml nginx_install ├── files │ └── INX - 1.17 . 2 .tar.gz ├── handlers ├── meta │ └── main.yml ├── Tasks │ ├── copy.yml │ ├── delete.yml │ ├── install.yml │ └── slim .yml ├── templates │ ├── index.html │ ├── index.php │ ├── install_nginx.sh │ ├── INX │ ├── nginx.conf │ └── vhost.conf └── VARs └── main.yml mysql_delete ├── files ├── handlers ├── meta │ └── main.yml ├── Tasks │ ├── delete.yml │ └── main.yml ├── templates └── VARs └── main.yml mysql_install ├── files │ └── mysql.tar.gz ├── handlers ├── meta │ └── main.yml ├── Tasks │ ├── copy.yml │ ├── delete.yml │ ├── install.yml │ └── main.yml ├── templates │ ├── install_mysql.sh │ ├── my.cnf │ ├── mysqld │ └ mysql_security.sh ── └── VARs └── main.yml php_delete ├── files ├── handlers ├── meta │ └── main.yml ├── Tasks │ ├── delete.yml │ └── slim. YML ├── templates │ └── delete_php.sh └── VARs └── main.yml php_install ├── files │ └── php.tar.gz ├── handlers ├── meta │ └── slim. YML ├── Tasks │ ├── copy.yml │ ├── delete.yml │ ├── install.yml │ └── main.yml ├── templates │ ├── install_php.sh │ ├── php - FPM │ └── php - fpm.conf └── VARs └── main.yml
5.playbook installation as follows:
- hosts: "`host`" remote_user: "`user`" gather_facts: True roles: - common - pcre_install - nginx_install - mysql_install - php_install
6. After the installation is complete, you can test access nginx