2025-12-06 23:44:17 +01:00
|
|
|
- name: Deploy personal blog static site with Caddy file server
|
2026-09-11 21:56:12 +02:00
|
|
|
hosts: edge
|
2025-12-06 23:44:17 +01:00
|
|
|
become: yes
|
|
|
|
|
vars_files:
|
|
|
|
|
- ./personal_blog_vars.yml
|
|
|
|
|
vars:
|
|
|
|
|
personal_blog_subdomain: "{{ subdomains.personal_blog }}"
|
|
|
|
|
personal_blog_domain: "{{ personal_blog_subdomain }}.{{ root_domain }}"
|
|
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
|
- name: Ensure user is in www-data group
|
|
|
|
|
user:
|
|
|
|
|
name: "{{ ansible_user }}"
|
|
|
|
|
groups: www-data
|
|
|
|
|
append: yes
|
|
|
|
|
|
|
|
|
|
- name: Create web root directory for personal blog
|
|
|
|
|
file:
|
|
|
|
|
path: "{{ personal_blog_web_root }}"
|
|
|
|
|
state: directory
|
|
|
|
|
owner: "{{ ansible_user }}"
|
|
|
|
|
group: www-data
|
|
|
|
|
mode: '2775'
|
|
|
|
|
|
|
|
|
|
- name: Fix ownership and permissions on web root directory
|
|
|
|
|
shell: |
|
|
|
|
|
chown -R {{ ansible_user }}:www-data {{ personal_blog_web_root }}
|
|
|
|
|
find {{ personal_blog_web_root }} -type d -exec chmod 2775 {} \;
|
|
|
|
|
find {{ personal_blog_web_root }} -type f -exec chmod 664 {} \;
|
|
|
|
|
|
|
|
|
|
- name: Create placeholder index.html
|
|
|
|
|
copy:
|
|
|
|
|
dest: "{{ personal_blog_web_root }}/index.html"
|
|
|
|
|
content: |
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
|
|
|
|
<title>Personal Blog</title>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<h1>Personal Blog</h1>
|
|
|
|
|
<p>Site is ready. Deploy your static files here.</p>
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|
|
|
|
|
owner: "{{ ansible_user }}"
|
|
|
|
|
group: www-data
|
|
|
|
|
mode: '0664'
|
|
|
|
|
|
2026-09-11 23:19:01 +02:00
|
|
|
- name: Publish the blog through Caddy
|
|
|
|
|
ansible.builtin.include_role:
|
|
|
|
|
name: caddy_site
|
|
|
|
|
vars:
|
|
|
|
|
caddy_site_name: personal-blog
|
|
|
|
|
caddy_site_domain: "{{ personal_blog_domain }}"
|
|
|
|
|
caddy_site_root: "{{ personal_blog_web_root }}"
|