You've already forked ansible-role-directadmin
139 lines
4.1 KiB
YAML
139 lines
4.1 KiB
YAML
---
|
|
|
|
- name: Check if DirectAdmin exists
|
|
stat:
|
|
path: /usr/local/directadmin/directadmin
|
|
register: da
|
|
|
|
- name: Configure pre-install options
|
|
when: not da.stat.exists
|
|
block:
|
|
- name: Ensure custombuild directory exists
|
|
file:
|
|
path: "{{ directadmin_custombuild_path }}"
|
|
state: directory
|
|
|
|
- name: Setup options for base install
|
|
template:
|
|
src: "{{ item.src }}"
|
|
dest: "{{ item.dest }}"
|
|
loop:
|
|
- name: options.conf
|
|
src: custombuild/options.conf.j2
|
|
dest: "{{ directadmin_custombuild_path }}/options.conf"
|
|
- name: php_extensions.conf
|
|
src: custombuild/php_extensions.conf.j2
|
|
dest: "{{ directadmin_custombuild_path }}/php_extensions.conf"
|
|
loop_control:
|
|
label: "{{ item.name }}"
|
|
# vars:
|
|
# directadmin_webserver: apache # Ensure is apache install for server name SSL
|
|
|
|
- name: Create file denotine LAN install
|
|
ansible.builtin.copy:
|
|
dest: /root/.lan
|
|
content: |
|
|
1
|
|
owner: root
|
|
group: root
|
|
mode: '0644'
|
|
when: directadmin_lan
|
|
|
|
- name: Download DirectAdmin installer
|
|
get_url:
|
|
url: https://download.directadmin.com/setup.sh
|
|
dest: /tmp/directadmin-setup.sh
|
|
mode: "0700"
|
|
|
|
- name: 'Coffee Time!'
|
|
debug:
|
|
msg: "Have a nice break, I'll be busy a while..."
|
|
|
|
- name: Send ntfy ping
|
|
uri:
|
|
url: https://ntfy.cybercinch.nz/
|
|
method: POST
|
|
body_format: json
|
|
body:
|
|
topic: ansiballz
|
|
title: DirectAdmin provisioning
|
|
tags:
|
|
- robot
|
|
- warning
|
|
- cd
|
|
message: DirectAdmin install is beginning on {{ inventory_hostname }}
|
|
|
|
- name: Run installer
|
|
shell: "{{ lookup('ansible.builtin.template', 'templates/cli/directadmin-setup.j2') }}"
|
|
|
|
- name: Send ntfy ping
|
|
uri:
|
|
url: https://ntfy.cybercinch.nz/
|
|
method: POST
|
|
body_format: json
|
|
body:
|
|
topic: ansiballz
|
|
title: DirectAdmin provisioning
|
|
tags:
|
|
- robot
|
|
- heavy_check_mark
|
|
message: DirectAdmin install is completed on {{ inventory_hostname }}
|
|
|
|
- name: Add new IPv6 to DA
|
|
template:
|
|
src: da-ip.j2
|
|
dest: /usr/local/directadmin/data/admin/ips/{{ hostvars[inventory_hostname]['ansible_default_ipv6']['address'] }}
|
|
owner: diradmin
|
|
group: diradmin
|
|
mode: "0600"
|
|
notify:
|
|
- Restart DirectAdmin
|
|
- Rewrite confs
|
|
|
|
- name: Retrieve Public IP
|
|
ansible.builtin.uri:
|
|
url: https://ipv4.icanhazip.com
|
|
return_content: true
|
|
register: pub_ip
|
|
when: directadmin_lan
|
|
|
|
|
|
- name: Reciprocal Link from Main IPv4 (Direct)
|
|
lineinfile:
|
|
path: /usr/local/directadmin/data/admin/ips/{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address']}}
|
|
line: "linked_ips={{ hostvars[inventory_hostname]['ansible_default_ipv6']['address'] | encode_ip }}=apache%3Dyes%26dns%3Dyes"
|
|
create: true
|
|
when: not directadmin_lan
|
|
notify:
|
|
- Restart DirectAdmin
|
|
- Rewrite confs
|
|
|
|
- name: Reciprocal Link from Main IPv4 (LAN)
|
|
lineinfile:
|
|
path: /usr/local/directadmin/data/admin/ips/{{ pub_ip.content }}
|
|
line: "linked_ips={{ hostvars[inventory_hostname]['ansible_default_ipv6']['address'] | encode_ip }}=apache%3Dyes%26dns%3Dyes"
|
|
create: true
|
|
when: directadmin_lan
|
|
notify:
|
|
- Restart DirectAdmin
|
|
- Rewrite confs
|
|
|
|
- name: Add IP to admin ip.list
|
|
ansible.builtin.lineinfile:
|
|
path: /usr/local/directadmin/data/admin/ip.list
|
|
line: "{{ hostvars[inventory_hostname]['ansible_default_ipv6']['address'] }}"
|
|
create: true
|
|
notify:
|
|
- Restart DirectAdmin
|
|
- Rewrite confs
|
|
|
|
- name: Flushing handlers
|
|
meta: flush_handlers
|
|
|
|
- name: Get Server Hostname SSL Certificate
|
|
import_tasks: letsencrypt.yml
|
|
|
|
# Tasks which can run whether new install or just config
|
|
- name: Include configuration tasks
|
|
include_tasks: config.yml
|