You've already forked ansible-directadmin
Initial commit, not fully tested, work in progress
This commit is contained in:
3
tasks/main.yml
Normal file
3
tasks/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- include: prerequisites.yml
|
||||
- include: setup.yml
|
||||
30
tasks/prerequisites-Debian.yml
Normal file
30
tasks/prerequisites-Debian.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
- name: Install dependencies for Debian 6 Squeeze
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
update_cache: yes
|
||||
cache_valid_time: "{{ directadmin_cache_timeout }}"
|
||||
state: present
|
||||
with_items:
|
||||
- "{{ directadmin_debian6_packages }}"
|
||||
when: "ansible_distribution == 'Debian' and ansible_distribution_release == 'squeeze'"
|
||||
|
||||
- name: Install dependencies for Debian 7 Wheezy
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
update_cache: yes
|
||||
cache_valid_time: "{{ directadmin_cache_timeout }}"
|
||||
state: present
|
||||
with_items:
|
||||
- "{{ directadmin_debian7_packages }}"
|
||||
when: "ansible_distribution == 'Debian' and ansible_distribution_release == 'wheezy'"
|
||||
|
||||
- name: Install dependencies for Debian 8 Jessie
|
||||
apt:
|
||||
name: "{{ item }}"
|
||||
update_cache: yes
|
||||
cache_valid_time: "{{ directadmin_cache_timeout }}"
|
||||
state: present
|
||||
with_items:
|
||||
- "{{ directadmin_debian8_packages }}"
|
||||
when: "ansible_distribution == 'Debian' and ansible_distribution_release == 'jessie'"
|
||||
26
tasks/prerequisites-RedHat.yml
Normal file
26
tasks/prerequisites-RedHat.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
---
|
||||
- name: install dependencies for RHEL, Fedora & CentOS
|
||||
yum:
|
||||
name: "{{ item }}"
|
||||
update_cache: yes
|
||||
state: present
|
||||
with_items:
|
||||
- "{{ directadmin_rhel_packages_generic }}"
|
||||
|
||||
- name: install everywhere but on CentOS7
|
||||
yum:
|
||||
name: "{{ item }}"
|
||||
update_cache: yes
|
||||
state: present
|
||||
with_items:
|
||||
- "{{ directadmin_rhel_packages }}"
|
||||
when: ansible_distribution not 'CentOS' and ansible_distribution_version|version_compare('ne', 7)
|
||||
|
||||
- name: install CentOS 7 specific requirements
|
||||
yum:
|
||||
name: "{{ item }}"
|
||||
update_cache: yes
|
||||
state: present
|
||||
with_items:
|
||||
- "{{ directadmin_centos7_packages }}"
|
||||
when: ansible_distribution == 'CentOS' and ansible_distribution_version|version_compare('=', 7)
|
||||
18
tasks/prerequisites.yml
Normal file
18
tasks/prerequisites.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
---
|
||||
# Ensure all variables are present to start with:
|
||||
- name: verify all required variables are set
|
||||
fail:
|
||||
msg: "Variable: '{{ item }}' is not defined!"
|
||||
when: "{{ item }} is undefined or {{ item }} is none"
|
||||
with_items:
|
||||
- directadmin_client_id
|
||||
- directadmin_license_id
|
||||
- directadmin_hostname
|
||||
|
||||
# Ensure prerequisites are installed for supported OS
|
||||
- include: prerequisites-Debian.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
|
||||
- include: prerequisites-RedHat.yml
|
||||
when: ansible_os_family == 'RedHat'
|
||||
|
||||
59
tasks/setup.yml
Normal file
59
tasks/setup.yml
Normal file
@@ -0,0 +1,59 @@
|
||||
---
|
||||
- name: obtain setup.sh script
|
||||
get_url:
|
||||
url: "{{ directadmin_setup_url }}"
|
||||
dest: "{{ directadmin_setup_path }}/"
|
||||
|
||||
- name: ensure proper permissions on setup.sh
|
||||
file:
|
||||
path: "{{ directadmin_setup_path }}/setup.sh"
|
||||
mode: 0755
|
||||
|
||||
- name: ensure custombuild version is set
|
||||
template:
|
||||
src: .custombuild.j2
|
||||
dest: "{{ directadmin_setup_path }}/.custombuild"
|
||||
|
||||
- name: check if DA is already running on host
|
||||
uri:
|
||||
url: http://localhost:2222
|
||||
return_content: no
|
||||
register: da_present
|
||||
|
||||
- name: toggle whether to install DA or not
|
||||
set_fact:
|
||||
directadmin_install: False
|
||||
when: da_present.status == 200
|
||||
|
||||
- block:
|
||||
- name: ensure directadmin path if remote options file is used
|
||||
file:
|
||||
path: "{{ directadmin_custombuild_path }}"
|
||||
recurse: yes
|
||||
state: directory
|
||||
|
||||
- name: try remote custombuild options file
|
||||
get_url:
|
||||
url: "{{ directadmin_custombuild_options_conf }}"
|
||||
dest: "{{ directadmin_custombuild_path }}/options.conf"
|
||||
|
||||
when: directadmin_custombuild_options_conf is defined and directadmin_custombuild_options_conf is not none
|
||||
|
||||
# https://youtu.be/b00j4WblrzA?t=238
|
||||
|
||||
- debug:
|
||||
msg: "This is a good time for a coffee break - https://xkcd.com/303/"
|
||||
when: directadmin_install
|
||||
|
||||
- name: run setup
|
||||
command: "{{ directadmin_setup_path }}/setup.sh {{ directadmin_client_id }} {{ directadmin_license_id }} {{ directadmin_hostname }} {{ directadmin_ethernet_device }} {{ directadmin_ip_address | default( hostvars[inventory_hostname]['ansible_' + directadmin_ethernet_device]['ipv4']['address'] ) }}"
|
||||
register: setup_output
|
||||
when: directadmin_install
|
||||
|
||||
- debug:
|
||||
var: setup_output.stdout_lines
|
||||
when: directadmin_install
|
||||
|
||||
- debug:
|
||||
msg: "Directadmin is already installed and running, skipping.."
|
||||
when: not directadmin_install
|
||||
Reference in New Issue
Block a user