|
[student@workstation ansible]$ tree v4.d
v4.d
├── files
│ ├── index-servera.html
│ ├── index-wwwa.html
│ ├── vhosts.conf
│ └── wwwa.pass
└── vars
└── secret.yml
2 directories, 5 files
[student@workstation ansible]$ cat v4.d/files/wwwa.pass ( htpasswd -c -m /文件名 用户名)
testuser1:$apr1$oE0D6Utk$qlU7cjjt8a0ic8/YAHR9e.
testuser2:{SHA}pkxl4cxVt6gakc2TDshJtkXy2p4=
隐含文件要拷贝到:/var/www/html/wwwa:
.htaccess:
- AuthName "servera test apache with user and password"
- AuthUserFile "/etc/httpd/wwwa.pass"
- AuthType Basic
- require valid-user
复制代码
[student@workstation ansible]$ cat v4.d/files/index-server1.html
Welcome to server1.example.com.
[student@workstation ansible]$ cat v4.d/files/index-www1.html
Welcome to www1.example.com.
[student@workstation ansible]$ cat v4.d/files/vhosts.conf(拷贝自/usr/share/doc/httpd/httpd-vhost.conf)
<VirtualHost *:80>
DocumentRoot "/var/www/html/servera"
<Directory "/var/www/html/servera">
<RequireAll>
Require all granted
Require not host serverc.lab.example.com
</RequireAll>
</Directory>
ServerName servera.lab.example.com
ErrorLog "/var/log/httpd/servera.lab.example.com-error.log"
CustomLog "/var/log/httpd/servera.lab.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/html/wwwa"
<Directory "/var/www/html/wwwa">
AllowOverride AuthConfig
</Directory>
ServerName wwwa.lab.example.com
ErrorLog "/var/log/httpd/wwwa.lab.example.com-error.log"
CustomLog "/var/log/httpd/wwwa.lab.example.com-access.log" common
</VirtualHost>
[student@workstation ansible]$
------------------------------------------------------------
[student@workstation ansible]$ ansible-vault view v4.d/vars/secret.yml --vault-password-file=v3.d/vault.pass
web_pass: redhat123
v4-1_server1_E.yml:
|
|