Compare commits

2 Commits

Author SHA1 Message Date
hyperized
160620477e Bring role up to spec (2.5+, Debian 9) and introduce LetsEncrypt support (#5)
* Bring role up to spec (2.5+) and introduce LetsEncrypt support
* Add Debian 9 support and fix script args chdir
* Use correct schema for travis and use command instead of script
* Make use of requirements.txt for build and fix syntax
* Got better at reading the docs now
* Minor improvements
2018-09-17 15:12:03 +02:00
hyperized
687042298e Fix test & syntax (#4)
* Optimize syntax
* Fix typo
2018-09-03 21:00:51 +02:00
13 changed files with 274 additions and 170 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.idea

View File

@@ -12,18 +12,19 @@ addons:
- python-pip - python-pip
install: install:
# Install ansible # Install requirements
- pip install ansible - pip install -r requirements.txt -U
# Check ansible version # Check ansible version
- ansible --version - ansible --version
# Create ansible.cfg with correct roles_path # Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg - printf '[defaults]\nroles_path=../' >ansible.cfg
script: script:
# Basic role syntax check # Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
notifications: notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/ webhooks:
- https://galaxy.ansible.com/api/v1/notifications/

View File

@@ -10,143 +10,189 @@ directadmin_setup_path: /root
directadmin_ethernet_device: eth0 directadmin_ethernet_device: eth0
directadmin_custombuild_options_conf: # like http://yourdomain.com/options.conf directadmin_custombuild_options_conf: # like http://yourdomain.com/options.conf
directadmin_custombuild_version: 2.0 directadmin_custombuild_version: 2.0
directadmin_custombuild_path: /usr/local/directadmin/custombuild directadmin_path: /usr/local/directadmin/
directadmin_config_path: "{{ directadmin_path }}conf/directadmin.conf"
directadmin_custombuild_path: "{{ directadmin_path }}custombuild"
directadmin_cache_timeout: 3600 directadmin_cache_timeout: 3600
directadmin_letsencrypt: True
# Packages - http://help.directadmin.com/item.php?id=354 # Packages - http://help.directadmin.com/item.php?id=354
directadmin_debian6_packages: directadmin_debian6_packages:
- gcc - gcc
- g++ - g++
- make - make
- flex - flex
- bison - bison
- openssl - openssl
- libssl-dev - libssl-dev
- perl - perl
- perl-base - perl-base
- perl-modules - perl-modules
- libperl-dev - libperl-dev
- libaio1 - libaio1
- libaio-dev - libaio-dev
- zlib1g - zlib1g
- zlib1g-dev - zlib1g-dev
- libcap-dev - libcap-dev
- bzip2 - bzip2
- automake - automake
- autoconf - autoconf
- libtool - libtool
- cmake - cmake
- pkg-config - pkg-config
- python - python
- libreadline-dev - libreadline-dev
- libdb4.8-dev - libdb4.8-dev
- libsasl2-dev - libsasl2-dev
- patch - patch
directadmin_debian7_packages: directadmin_debian7_packages:
- gcc - gcc
- g++ - g++
- make - make
- flex - flex
- bison - bison
- openssl - openssl
- libssl-dev - libssl-dev
- perl - perl
- perl-base - perl-base
- perl-modules - perl-modules
- libperl-dev - libperl-dev
- libaio1 - libaio1
- libaio-dev - libaio-dev
- zlib1g - zlib1g
- zlib1g-dev - zlib1g-dev
- libcap-dev - libcap-dev
- bzip2 - bzip2
- automake - automake
- autoconf - autoconf
- libtool - libtool
- cmake - cmake
- pkg-config - pkg-config
- python - python
- libdb-dev - libdb-dev
- libsasl2-dev - libsasl2-dev
- libncurses5-dev - libncurses5-dev
- patch - patch
directadmin_debian8_packages: directadmin_debian8_packages:
- gcc - gcc
- g++ - g++
- make - make
- flex - flex
- bison - bison
- openssl - openssl
- libssl-dev - libssl-dev
- perl - perl
- perl-base - perl-base
- perl-modules - perl-modules
- libperl-dev - libperl-dev
- libaio1 - libaio1
- libaio-dev - libaio-dev
- zlib1g - zlib1g
- zlib1g-dev - zlib1g-dev
- libcap-dev - libcap-dev
- bzip2 - bzip2
- automake - automake
- autoconf - autoconf
- libtool - libtool
- cmake - cmake
- pkg-config - pkg-config
- python - python
- libdb-dev - libdb-dev
- libsasl2-dev - libsasl2-dev
- libncurses5-dev - libncurses5-dev
- libsystemd-dev - libsystemd-dev
- bind9 - bind9
- quota - quota
- libsystemd-daemon0 - libsystemd-daemon0
- patch - patch
- libjemalloc-dev - libjemalloc-dev
directadmin_debian9_packages:
- autoconf
- automake
- bind9
- bison
- bsd-mailx
- bzip2
- cmake
- cron
- dnsutils
- flex
- g++
- gcc
- libaio-dev
- libaio1
- libc6-dev
- libcap-dev
- libcrypt-openssl-rsa-perl
- libdb-dev
- libexpat1-dev
- libjemalloc-dev
- libncurses5-dev
- libnuma-dev
- libnuma1
- libperl-dev
- libsasl2-dev
- libssl-dev
- libsystemd-dev
- libtool
- logrotate
- make
- openssl
- patch
- perl
- perl-base
- perl-modules
- pkg-config
- python
- quota
- rsyslog
- zlib1g
- zlib1g-dev
directadmin_rhel_generic_packages: directadmin_rhel_generic_packages:
- gcc - gcc
- gcc-c++ - gcc-c++
- flex - flex
- bison - bison
- make - make
- bind - bind
- bind-libs - bind-libs
- bind-utils - bind-utils
- openssl - openssl
- openssl-devel - openssl-devel
- perl - perl
- quota - quota
- libaio - libaio
- libcom_err-devel - libcom_err-devel
- libcurl-devel - libcurl-devel
- gd - gd
- zlib-devel - zlib-devel
- zip - zip
- unzip - unzip
- libcap-devel - libcap-devel
- cronie - cronie
- bzip2 - bzip2
- cyrus-sasl-devel - cyrus-sasl-devel
- perl-ExtUtils-Embed - perl-ExtUtils-Embed
- autoconf - autoconf
- automake - automake
- libtool - libtool
- which - which
- patch - patch
- mailx - mailx
- bzip2-devel - bzip2-devel
- lsof - lsof
directadmin_rhel_packages: directadmin_rhel_packages:
- db4-devel - db4-devel
directadmin_centos7_packages: directadmin_centos7_packages:
- psmisc - psmisc
- net-tools - net-tools
- systemd-devel - systemd-devel
- libdb-devel - libdb-devel
- perl-DBI - perl-DBI
- xfsprogs - xfsprogs

5
handlers/main.yml Normal file
View File

@@ -0,0 +1,5 @@
---
- name: restart directadmin
service:
name: directadmin
state: restarted

View File

@@ -1,9 +1,10 @@
---
galaxy_info: galaxy_info:
author: Gerben Geijteman author: Gerben Geijteman
description: Deploy DirectAdmin with Ansible description: Deploy DirectAdmin with Ansible
company: Hyperized Hosting company: Hyperized Hosting
license: MIT license: MIT
min_ansible_version: 2.1 min_ansible_version: 2.5
platforms: platforms:
- name: EL - name: EL
versions: versions:
@@ -16,6 +17,7 @@ galaxy_info:
- jessie - jessie
- squeeze - squeeze
- wheezy - wheezy
- stretch
galaxy_tags: galaxy_tags:
- system - system
- web - web

1
requirements.txt Normal file
View File

@@ -0,0 +1 @@
ansible

23
tasks/letsencrypt.yml Normal file
View File

@@ -0,0 +1,23 @@
---
- name: execute LetsEncrypt setup script
command: letsencrypt.sh request_single {{ directadmin_hostname }} 4096
args:
chdir: /usr/local/directadmin/scripts/
register: directadmin_letsencrypt_output
- debug:
var: directadmin_letsencrypt_output.stdout_lines
- name: enable SSL with LetsEncrypt for DirectAdmin
lineinfile:
path: directadmin_config_path
regexp: item.regexp
line: item.line
with_items:
- { regexp: '^SSL\=0' , line: 'SSL=1' }
- { regexp: '^carootcert=' , line: 'carootcert=/usr/local/directadmin/conf/carootcert.pem' }
- { regexp: '^force_hostname=' , line: "force_hostname={{ directadmin_hostname }}" }
- { regexp: '^ssl_redirect_host=' , line: "ssl_redirect_host={{ directadmin_hostname }}" }
- { regexp: '^letsencrypt=' , line: "letsencrypt=1" }
notify:
- restart directadmin

View File

@@ -7,7 +7,9 @@
state: present state: present
with_items: with_items:
- "{{ directadmin_debian6_packages }}" - "{{ directadmin_debian6_packages }}"
when: "ansible_distribution == 'Debian' and ansible_distribution_release == 'squeeze'" when:
- ansible_distribution == 'Debian'
- ansible_distribution_release == 'squeeze'
- name: Install dependencies for Debian 7 Wheezy - name: Install dependencies for Debian 7 Wheezy
apt: apt:
@@ -17,9 +19,23 @@
state: present state: present
with_items: with_items:
- "{{ directadmin_debian7_packages }}" - "{{ directadmin_debian7_packages }}"
when: "ansible_distribution == 'Debian' and ansible_distribution_release == 'wheezy'" when:
- ansible_distribution == 'Debian'
- ansible_distribution_release == 'wheezy'
- name: Install dependencies for Debian 8 Jessie - name: Install dependencies for Debian 8 Jessie
apt:
name: "{{ item }}"
update_cache: yes
cache_valid_time: "{{ directadmin_cache_timeout }}"
state: present
with_items:
- "{{ directadmin_debian9_packages }}"
when:
- ansible_distribution == 'Debian'
- ansible_distribution_release == 'jessie'
- name: Install dependencies for Debian 9 Stretch
apt: apt:
name: "{{ item }}" name: "{{ item }}"
update_cache: yes update_cache: yes
@@ -27,4 +43,6 @@
state: present state: present
with_items: with_items:
- "{{ directadmin_debian8_packages }}" - "{{ directadmin_debian8_packages }}"
when: "ansible_distribution == 'Debian' and ansible_distribution_release == 'jessie'" when:
- ansible_distribution == 'Debian'
- ansible_distribution_release == 'jessie'

View File

@@ -5,7 +5,7 @@
update_cache: yes update_cache: yes
state: present state: present
with_items: with_items:
- "{{ directadmin_rhel_packages_generic }}" - "{{ directadmin_rhel_generic_packages }}"
- name: install everywhere but on CentOS7 - name: install everywhere but on CentOS7
yum: yum:
@@ -14,7 +14,9 @@
state: present state: present
with_items: with_items:
- "{{ directadmin_rhel_packages }}" - "{{ directadmin_rhel_packages }}"
when: ansible_distribution not 'CentOS' and ansible_distribution_version|version_compare('ne', 7) when:
- ansible_distribution not 'CentOS'
- ansible_distribution_version is version(7, 'ne')
- name: install CentOS 7 specific requirements - name: install CentOS 7 specific requirements
yum: yum:
@@ -23,4 +25,6 @@
state: present state: present
with_items: with_items:
- "{{ directadmin_centos7_packages }}" - "{{ directadmin_centos7_packages }}"
when: ansible_distribution == 'CentOS' and ansible_distribution_version|version_compare('=', 7) when:
- ansible_distribution is 'CentOS'
- ansible_distribution_version is version(7, '=')

View File

@@ -14,16 +14,15 @@
src: .custombuild.j2 src: .custombuild.j2
dest: "{{ directadmin_setup_path }}/.custombuild" dest: "{{ directadmin_setup_path }}/.custombuild"
- name: check if DA is already running on host - name: check if DA is already present on host
uri: stat:
url: http://localhost:2222 path: "{{ directadmin_config_path }}"
return_content: no register: directadmin_present
register: da_present
- name: toggle whether to install DA or not - name: toggle whether to install DA or not
set_fact: set_fact:
directadmin_install: False directadmin_install: False
when: da_present.status == 200 when: directadmin_present.stat.exists == True
- block: - block:
- name: ensure directadmin path if remote options file is used - name: ensure directadmin path if remote options file is used
@@ -54,6 +53,10 @@
var: setup_output.stdout_lines var: setup_output.stdout_lines
when: directadmin_install when: directadmin_install
- name: ensure Letsencrypt
include: letsencrypt.yml
when: directadmin_letsencrypt
- debug: - debug:
msg: "Directadmin is already installed and running, skipping.." msg: "Directadmin is already installed and running, skipping.."
when: not directadmin_install when: not directadmin_install