geerlingguy.htpasswd
Ansibleロール: htpasswd
htpasswd
をインストールし、Linuxサーバー上での htpasswd
認証ファイルと資格情報(ApacheやNginxなどのウェブサーバーでのHTTP基本認証に使用)の簡単な設定を可能にするAnsibleロールです。
要件
なし。
ロール変数
利用可能な変数は以下に示されており、デフォルト値も記載されています(defaults/main.yml
を参照):
htpasswd_nolog: true
Ansibleのログ出力にhtpasswdの資格情報を表示するかどうか。何かをデバッグしていない限り、true
のままにしておくべきです。
htpasswd_credentials:
- path: /etc/nginx/passwdfile
name: johndoe
password: 'supersecure'
owner: root
group: www-data
mode: 'u+rw,g+r'
- path: /etc/apache2/passwdfile
name: janedoe
password: 'supersecure'
owner: root
group: www-data
mode: 'u+rw,g+r'
それぞれのディクショナリで定義された path
キーに対して生成(または削除)される資格情報のリスト。mode
を除くすべてのパラメータが必要です(mode
のデフォルトは 'u+rw,g+r'
(0640
オクタル)です)。
htpasswd_required_packages:
- apache2-utils
- python3-passlib
(表示されているのはDebianのデフォルトです)。この変数を使ってインストールされるパッケージを上書きできます(例えば、CentOS 7の場合、python3-passlib
を python-passlib
に変更できます)。
依存関係
なし。
例 Playbook
Apacheの例
---
- hosts: apache-server
vars:
htpasswd_credentials:
- path: /etc/apache-passwdfile
name: johndoe
password: 'supersecure'
owner: root
group: apache
mode: 'u+rw,g+r'
apache_remove_default_vhost: True
apache_vhosts:
- listen: "80"
servername: "htpassword.test"
documentroot: "/var/www/html"
extra_parameters: |
<Directory "/var/www/html">
AuthType Basic
AuthName "Apache with basic auth."
AuthUserFile /etc/apache-passwdfile
Require valid-user
</Directory>
pre_tasks:
- name: aptキャッシュを更新します。
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'
roles:
- geerlingguy.apache
- geerlingguy.htpasswd
Nginxの例
---
- hosts: nginx-server
vars:
htpasswd_credentials:
- path: /etc/nginx/passwdfile
name: johndoe
password: 'supersecure'
owner: root
group: www-data
mode: 'u+rw,g+r'
nginx_remove_default_vhost: True
nginx_vhosts:
- listen: "80"
server_name: "htpassword.test"
root: "/var/www/html"
index: "index.html index.html index.nginx-debian.html"
filename: "htpassword.test.conf"
extra_parameters: |
location / {
auth_basic "Nginx with basic auth.";
auth_basic_user_file /etc/nginx/passwdfile;
}
pre_tasks:
- name: aptキャッシュを更新します。
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'
roles:
- geerlingguy.nginx
- geerlingguy.htpasswd
ライセンス
MIT / BSD
作者情報
このロールは2018年にJeff Geerlingによって作成されました。Ansible for DevOpsの著者です。
プロジェクトについて
htpasswd installation and helper role for Linux servers.
インストール
ansible-galaxy install geerlingguy.htpasswd
ライセンス
mit
ダウンロード
139.6k
所有者
Father, author, developer, maker. Sometimes called "an inflammatory enigma". #stl #drupal #ansible #k8s #raspberrypi #crohns