A sample to provision Lets’ Encrypt for Nginx on Ubuntu 18.04 by Ansible 2.9.
Ubuntu 18.04 に Ansible で Let’s Encrypt を設定するサンプル。
- Put a configuration only to get certificates with certbot
- Do certbot with webroot
- Then change the configuration to a configuration with SSL
Write your machine name or an ip address to hosts
.
Rewrite a list domains
in ./roles/get-certs/tasks/main.yml
and set letsencrypt_email
as your email address.
- name: Get certs
vars:
domains:
- hoge.example.net
- fuga.example.net
letsencrypt_email: [email protected]
And then do ansible-playbook
.
ansible-playbook -i hosts site.yml
- 一旦 certbot で証明書を取得するためだけの nginx 設定ファイルを設定する
- その状態で nginx を立ち上げて webroot で certbot する
- その後で SSL 設定付きの nginx 設定ファイルを書き込む
hosts
ファイルにプロビジョニングしたいマシンを書き込みます。
./roles/get-certs/tasks/main.yml
の中にある次の domains
というリストを必要な分だけ書きます。 letsencrypt_email
にメールアドレスも設定します。
- name: Get certs
vars:
domains:
- hoge.example.net
- fuga.example.net
letsencrypt_email: [email protected]
そして ansible-playbook
します。
ansible-playbook -i hosts site.yml