You've already forked ansible-directadmin
Initial commit, not fully tested, work in progress
This commit is contained in:
29
.travis.yml
Normal file
29
.travis.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
language: python
|
||||
python: "2.7"
|
||||
|
||||
# Use the new container infrastructure
|
||||
sudo: false
|
||||
|
||||
# Install ansible
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- python-pip
|
||||
|
||||
install:
|
||||
# Install ansible
|
||||
- pip install ansible
|
||||
|
||||
# Check ansible version
|
||||
- ansible --version
|
||||
|
||||
# Create ansible.cfg with correct roles_path
|
||||
- printf '[defaults]\nroles_path=../' >ansible.cfg
|
||||
|
||||
script:
|
||||
# Basic role syntax check
|
||||
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016
|
||||
Copyright (c) 2016
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
58
README.md
Normal file
58
README.md
Normal file
@@ -0,0 +1,58 @@
|
||||
Role Name
|
||||
=========
|
||||
|
||||
Deploy [DirectAdmin](https://directadmin.com/) with Ansible
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
- A DirectAdmin license is required.
|
||||
- A clean machine is required. DirectAdmin will actively overwrite existing packages.
|
||||
- A publicly reachable IP is required.
|
||||
- Root access to the target machine is required. For details, read: [Step 3](https://www.directadmin.com/installguide.php)
|
||||
|
||||
Ansible 2.1 is highly recommended.
|
||||
|
||||
Role Variables
|
||||
--------------
|
||||
|
||||
Its recommended that you use either the `group_vars` / `host_vars` to set the required variables per server:
|
||||
|
||||
directadmin_client_id:
|
||||
directadmin_license_id:
|
||||
directadmin_hostname: # Optional, will be obtained from server
|
||||
directadmin_ip_address: # Optional, will be obtained from server
|
||||
|
||||
If you wish to use a custom custombuild configuration, please configure:
|
||||
|
||||
directadmin_custombuild_options_conf: http://yourdomain.com/options.conf
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
As of present there are no dependent roles. (They may be added later)
|
||||
|
||||
Recommended to have installed on your server are:
|
||||
|
||||
- Firewall
|
||||
- SSH protection (Fail2Ban)
|
||||
- Kernel hardening
|
||||
|
||||
FreeBSD support may be added later.
|
||||
|
||||
Example Playbook
|
||||
----------------
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- { role: hyperized.directadmin }
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
MIT
|
||||
|
||||
Author Information
|
||||
------------------
|
||||
|
||||
Gerben Geijteman <gerben@hyperized.net>
|
||||
152
defaults/main.yml
Normal file
152
defaults/main.yml
Normal file
@@ -0,0 +1,152 @@
|
||||
---
|
||||
# Directadmin automated setup - http://help.directadmin.com/item.php?id=578
|
||||
directadmin_install: True
|
||||
directadmin_setup_url: http://www.directadmin.com/setup.sh
|
||||
directadmin_setup_path: /root
|
||||
# directadmin_client_id:
|
||||
# directadmin_license_id:
|
||||
# directadmin_hostname: # Optional, will be obtained from server
|
||||
# directadmin_ip_address: # Optional, will be obtained from server
|
||||
directadmin_ethernet_device: eth0
|
||||
directadmin_custombuild_options_conf: # like http://yourdomain.com/options.conf
|
||||
directadmin_custombuild_version: 2.0
|
||||
directadmin_custombuild_path: /usr/local/directadmin/custombuild
|
||||
directadmin_cache_timeout: 3600
|
||||
|
||||
# Packages - http://help.directadmin.com/item.php?id=354
|
||||
directadmin_debian6_packages:
|
||||
- gcc
|
||||
- g++
|
||||
- make
|
||||
- flex
|
||||
- bison
|
||||
- openssl
|
||||
- libssl-dev
|
||||
- perl
|
||||
- perl-base
|
||||
- perl-modules
|
||||
- libperl-dev
|
||||
- libaio1
|
||||
- libaio-dev
|
||||
- zlib1g
|
||||
- zlib1g-dev
|
||||
- libcap-dev
|
||||
- bzip2
|
||||
- automake
|
||||
- autoconf
|
||||
- libtool
|
||||
- cmake
|
||||
- pkg-config
|
||||
- python
|
||||
- libreadline-dev
|
||||
- libdb4.8-dev
|
||||
- libsasl2-dev
|
||||
- patch
|
||||
|
||||
directadmin_debian7_packages:
|
||||
- gcc
|
||||
- g++
|
||||
- make
|
||||
- flex
|
||||
- bison
|
||||
- openssl
|
||||
- libssl-dev
|
||||
- perl
|
||||
- perl-base
|
||||
- perl-modules
|
||||
- libperl-dev
|
||||
- libaio1
|
||||
- libaio-dev
|
||||
- zlib1g
|
||||
- zlib1g-dev
|
||||
- libcap-dev
|
||||
- bzip2
|
||||
- automake
|
||||
- autoconf
|
||||
- libtool
|
||||
- cmake
|
||||
- pkg-config
|
||||
- python
|
||||
- libdb-dev
|
||||
- libsasl2-dev
|
||||
- libncurses5-dev
|
||||
- patch
|
||||
|
||||
directadmin_debian8_packages:
|
||||
- gcc
|
||||
- g++
|
||||
- make
|
||||
- flex
|
||||
- bison
|
||||
- openssl
|
||||
- libssl-dev
|
||||
- perl
|
||||
- perl-base
|
||||
- perl-modules
|
||||
- libperl-dev
|
||||
- libaio1
|
||||
- libaio-dev
|
||||
- zlib1g
|
||||
- zlib1g-dev
|
||||
- libcap-dev
|
||||
- bzip2
|
||||
- automake
|
||||
- autoconf
|
||||
- libtool
|
||||
- cmake
|
||||
- pkg-config
|
||||
- python
|
||||
- libdb-dev
|
||||
- libsasl2-dev
|
||||
- libncurses5-dev
|
||||
- libsystemd-dev
|
||||
- bind9
|
||||
- quota
|
||||
- libsystemd-daemon0
|
||||
- patch
|
||||
- libjemalloc-dev
|
||||
|
||||
directadmin_rhel_generic_packages:
|
||||
- gcc
|
||||
- gcc-c++
|
||||
- flex
|
||||
- bison
|
||||
- make
|
||||
- bind
|
||||
- bind-libs
|
||||
- bind-utils
|
||||
- openssl
|
||||
- openssl-devel
|
||||
- perl
|
||||
- quota
|
||||
- libaio
|
||||
- libcom_err-devel
|
||||
- libcurl-devel
|
||||
- gd
|
||||
- zlib-devel
|
||||
- zip
|
||||
- unzip
|
||||
- libcap-devel
|
||||
- cronie
|
||||
- bzip2
|
||||
- cyrus-sasl-devel
|
||||
- perl-ExtUtils-Embed
|
||||
- autoconf
|
||||
- automake
|
||||
- libtool
|
||||
- which
|
||||
- patch
|
||||
- mailx
|
||||
- bzip2-devel
|
||||
- lsof
|
||||
|
||||
directadmin_rhel_packages:
|
||||
- db4-devel
|
||||
|
||||
directadmin_centos7_packages:
|
||||
- psmisc
|
||||
- net-tools
|
||||
- systemd-devel
|
||||
- libdb-devel
|
||||
- perl-DBI
|
||||
- xfsprogs
|
||||
23
meta/main.yml
Normal file
23
meta/main.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
galaxy_info:
|
||||
author: Gerben Geijteman
|
||||
description: Deploy DirectAdmin with Ansible
|
||||
company: Hyperized Hosting
|
||||
license: MIT
|
||||
min_ansible_version: 2.1
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- all
|
||||
- name: Fedora
|
||||
versions:
|
||||
- all
|
||||
- name: Debian
|
||||
versions:
|
||||
- jessie
|
||||
- squeeze
|
||||
- wheezy
|
||||
galaxy_tags:
|
||||
- system
|
||||
- web
|
||||
- directadmin
|
||||
dependencies: []
|
||||
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
|
||||
1
templates/options.conf.j2
Normal file
1
templates/options.conf.j2
Normal file
@@ -0,0 +1 @@
|
||||
{{ directadmin_custombuild_version }}
|
||||
1
tests/inventory
Normal file
1
tests/inventory
Normal file
@@ -0,0 +1 @@
|
||||
localhost
|
||||
5
tests/test.yml
Normal file
5
tests/test.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
roles:
|
||||
- ansible-directadmin
|
||||
Reference in New Issue
Block a user