Commit b43fc233 authored by Clément Igonet's avatar Clément Igonet

website

parent 99453ee7
......@@ -15,6 +15,12 @@
- "cifs-utils"
- "nfs-common"
- "apt-utils"
- "nodejs"
register: packages
become: yes
- debug: var=packages.stdout_lines
- shell: |
cd /usr/bin
ln -sf /usr/bin/nodejs node
become: yes
---
- hosts: all
roles:
- role: caddy-ansible-tunned
caddy_config: |
integration.openearthview.net {
tls contact@openearthview.net
root /var/www/viewer-earth-api-integration
gzip
}
www.openearthview.net {
tls contact@openearthview.net
root /var/www/website
gzip
}
become: yes
# - role: caddy-ansible
# caddy_update: yes
# caddy_email: contact@openearthview.net
#
# ---
# - hosts: all
# roles:
# - role: caddy-ansible
# caddy_config: |
# localhost:2020
# gzip
# root /var/www
# git github.com/antoiner77/caddy-ansible /
......@@ -9,16 +9,12 @@
- name: Add apt key to the system
apt_key: url=http://pkg.jenkins.io/debian-stable/jenkins.io.key state=present
become: yes
register: addAptKey
- debug: var=addAptKey
# Then add the following entry in your /etc/apt/sources.list:
# deb http://pkg.jenkins.io/debian-stable binary/
- name: Add deb entry to /etc/apt/sources.list
apt_repository: repo='deb http://pkg.jenkins.io/debian-stable binary/' state=present
become: yes
register: addDebEntry
- debug: var=addDebEntry
# Update your local package index, then finally install Jenkins:
# sudo apt-get update
......
......@@ -19,10 +19,11 @@
register: setupNpmRepo
- debug: var=setupNpmRepo
- name: install npm packages
- name: install node.js packages
apt: name={{ item }} state=latest update_cache=yes
with_items:
- "nodejs"
- "npm"
become: yes
register: npmPackages
- debug: var=npmPackages
#!/bin/sh
PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true \
ANSIBLE_HOST_KEY_CHECKING=false \
ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o ControlMaster=auto -o ControlPersist=60s' \
ansible-playbook \
--private-key=~/.ssh/id_rsa_becky \
--user=oev \
--connection=ssh \
--inventory-file=./inventory \
--limit='becky.framasoft.org' \
-vvvv \
--extra-vars "ansible_sudo_pass=$2" \
./$1
......@@ -8,5 +8,7 @@
- include: iptables.yml
- include: gitRepo.yml
- include: jenkins.yml
- include: caddy.yml
- include: caddy-ansible-tunned.yml
- include: npm.yml
- include: viewer-earth-api-integration.yml
- include: website.yml
#!/bin/sh
ansible-galaxy install -r requirements.yml -p roles
- src: antoiner77.caddy
version: v2.0.0
name: caddy-ansible
# - src: https://github.com/antoiner77/caddy-ansible
# version: v2.0.0
This diff is collapsed.
---
language: python
python: "2.7"
sudo: true
# 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
- ansible-playbook tests/test.yml -i tests/inventory --connection=local
- ansible-playbook tests/test.yml -i tests/inventory --connection=local
- >
ansible-playbook tests/test.yml -i tests/inventory --connection=local
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
[![Build Status](https://travis-ci.org/antoiner77/caddy-ansible.svg?branch=master)](https://travis-ci.org/antoiner77/caddy-ansible)
[![Galaxy Role](https://img.shields.io/badge/ansible--galaxy-caddy-blue.svg)](https://galaxy.ansible.com/antoiner77/caddy/)
Caddy Ansible Role
=========
This role installs and configures the caddy web server. The user can specify any http configuration parameters they wish to apply their site. Any number of sites can be added with configurations of your choice.
Dependencies
------------
None
Role Variables
--------------
**The [Caddyfile](https://caddyserver.com/docs/caddyfile)** (notice the pipe)<br>
default:
```
caddy_config: |
localhost:2020
gzip
root /var/www
git github.com/antoiner77/caddy-ansible /
```
**Auto update Caddy?**<br>
default:
```
caddy_update: yes
```
**Features that can be added to core:** cors,git,hugo,ipfilter,jsonp,search<br>
Changing this variable will reinstall Caddy with the new features if `caddy_update` is enabled<br>
default:
```
caddy_features: git
```
Example Playbook
----------------
```
---
- hosts: all
roles:
- role: caddy-ansible
caddy_email: foo@foo.bar
caddy_config: |
localhost:2020
gzip
root /var/www
git github.com/antoiner77/caddy-ansible /
```
Debugging
---------
If the service fails to start you can figure out why by looking at the output of Caddy.<br>
**Upstart (ubuntu, debian wheezy, centos/rhel 6)**<br>
`tail /var/log/upstart/caddy.log`<br>
**Systemd (debian jessie, centos/rhel 7)**<br>
`systemctl status caddy -l`
If something doesn't seem right, open an issue!
Contributing
------------
Pull requests are welcome. Please test your changes beforehand with vagrant:
```
vagrant up
vagrant provision (since it already provisioned there should be no changes here)
vagrant destroy
```
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.define "jessie" do |jessie|
jessie.vm.box = "debian/jessie64"
end
config.vm.define "precise" do |precise|
precise.vm.box = "ubuntu/precise64"
end
config.vm.define "trusty" do |trusty|
trusty.vm.box = "ubuntu/trusty64"
end
config.vm.define "centos7" do |centos7|
centos7.vm.box = "puppetlabs/centos-7.2-64-nocm"
end
config.vm.define "fedora22" do |fedora22|
fedora22.vm.box = "box-cutter/fedora22"
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = 'tests/test.yml'
end
$script = <<SCRIPT
# curl localhost and get the http response code
while ! curl -Is localhost:2020 -o /dev/null; do
sleep 1 && echo -n .
done
http_code=$(curl --silent --head --output /dev/null -w '%{http_code}' localhost:2020)
case $http_code in
200|404) echo "$http_code | Server running" ;;
000) echo "$http_code | Server not accessible!" >&2 ;;
*) echo "$http_code | Unknown http response code!" >&2 ;;
esac
SCRIPT
# Fix 'stdin: is not a tty' error
config.ssh.pty = true
config.vm.provision :shell, inline: $script
config.vm.synced_folder ".", "/vagrant", disabled: true
end
---
# defaults file for caddy-ansible
caddy_user: www-data
caddy_home: /home/caddy
caddy_features: git
caddy_update: yes
caddy_config: |
localhost:2020
gzip
root /var/www
git github.com/antoiner77/caddy-ansible /
---
# handlers file for caddy-ansible
- name: Restart Caddy
service: name=caddy state=restarted
- name: Reload systemd service file
command: systemctl daemon-reload
notify: Restart Caddy
ignore_errors: yes
{install_date: 'Mon Sep 26 03:21:42 2016', version: v2.0.0}
---
galaxy_info:
author: antoiner77
description: Installs and configures a Caddy webserver
# Some suggested licenses:
# - BSD (default)
# - MIT
# - GPLv2
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
min_ansible_version: 1.2
# Below are all platforms currently available. Just uncomment
# the ones that apply to your role. If you don't see your
# platform on this list, let us know and we'll get it added!
#
platforms:
- name: EL
versions:
- 7
- name: Ubuntu
versions:
- precise
- trusty
- name: Debian
versions:
- jessie
- name: Fedora
versions:
- 22
galaxy_tags:
- system
- web
dependencies: []
---
- include: packages-{{ ansible_pkg_mgr }}.yml
- name: Create Caddy user
user: name={{ caddy_user }} system=yes createhome=yes home={{ caddy_home }}
- name: Get all Caddy releases
get_url: url=https://api.github.com/repos/mholt/caddy/git/refs/tags dest={{ caddy_home }}/releases.txt force=yes
when: caddy_update
register: caddy_releases_cache
- name: Set Caddy features
copy: content="{{ caddy_features }}" dest={{ caddy_home }}/features.txt
when: caddy_update
register: caddy_features_cache
- name: Download Caddy
get_url: url=https://caddyserver.com/download/build?os=linux&arch=amd64&features={{ caddy_features }} dest={{ caddy_home }}/caddy.tar.gz force=yes
when: caddy_releases_cache.changed or caddy_features_cache.changed
register: caddy_binary_cache
- name: Download Caddy
get_url: url=https://caddyserver.com/download/build?os=linux&arch=amd64&features={{ caddy_features }} dest={{ caddy_home }}/caddy.tar.gz
- name: Extract Caddy
unarchive: src={{ caddy_home }}/caddy.tar.gz dest={{ caddy_home }} copy=no owner={{ caddy_user }}
when: caddy_binary_cache.changed
- name: Extract Caddy
unarchive: src={{ caddy_home }}/caddy.tar.gz dest={{ caddy_home }} creates={{ caddy_home }}/caddy copy=no owner={{ caddy_user }}
- name: Copy Caddy Binary
copy: src={{ caddy_home }}/caddy dest=/usr/local/bin/ mode=0755 remote_src=True
notify: Restart Caddy
- name: Create directories
file: path={{ item }} state=directory owner={{ caddy_user }} mode=0700
with_items:
- /etc/caddy
- /etc/ssl/caddy
- /var/www
- /var/log/caddy
- name: Create Caddyfile
copy: content="{{caddy_config}}" dest=/etc/caddy/Caddyfile owner={{ caddy_user }}
notify: Restart Caddy
- name: Check if systemd is running
stat: path=/run/systemd/system
register: systemd
- name: Upstart service
copy: src={{ caddy_home }}/init/linux-upstart/caddy.conf dest=/etc/init/caddy.conf mode=0644 remote_src=True
when: not systemd.stat.exists
notify: Restart Caddy
- name: Systemd service
copy: src={{ caddy_home }}/init/linux-systemd/caddy.service dest=/etc/systemd/system/caddy.service mode=0755 remote_src=True
when: systemd.stat.exists
- name: Systemd service
lineinfile:
dest: /etc/systemd/system/caddy.service
state: present
regexp: '^NoNewPrivileges=true'
line: '#NoNewPrivileges=true'
when: systemd.stat.exists
notify: Restart Caddy
- name: Check if the binary can bind to TCP port <1024
shell: getcap /usr/local/bin/caddy | grep cap_net_bind_service
failed_when: False
changed_when: False
when: not systemd.stat.exists
register: caddy_bind_cap
- name: Set capability on the binary file to be able to bind to TCP port <1024
command: setcap cap_net_bind_service=+ep /usr/local/bin/caddy
# when: not systemd.stat.exists and caddy_bind_cap.rc > 0
- name: Start Caddy service
service: name=caddy state=started enabled=yes
---
- name: Install git
apt: name=git update_cache=yes
when: caddy_features | search('git')
- name: Install libcap
apt: name=libcap2-bin
---
- name: Install git
dnf: name=git
when: caddy_features | search('git')
---
- name: Install git
yum: name=git
when: caddy_features | search('git')
---
- hosts: all
become: yes
roles:
- caddy-ansible
---
- name: viewer-earth-api-integration
hosts: all
tasks:
- name: npm install
shell: |
cd ~/Projects/OpenEarthView/viewer-earth-api-integration
npm install
register: npmInstall
- debug: var=npmInstall
- name: share
shell: |
cp -r /home/oev/Projects/OpenEarthView/viewer-earth-api-integration /var/www/
chown -R www-data:www-data /var/www/
become: yes
# - name: share
# copy:
# src: /home/oev/Projects/OpenEarthView/viewer-earth-api-integration
# dest: /var/www/
# remote_src: True
# owner: www-data
# group: www-data
# become: yes
---
- name: website
hosts: all
tasks:
# - name: share
# copy:
# src: /home/oev/Projects/OpenEarthView/website
# dest: /var/www/
# remote_src: True
# owner: www-data
# group: www-data
# become: yes
- name: Install bower
npm: name=bower global=yes
become: yes
- name: Bower install
bower: path=/home/oev/Projects/OpenEarthView/website
- name: share
shell: |
cp -r /home/oev/Projects/OpenEarthView/website /var/www/
chown -R www-data:www-data /var/www/
become: yes
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment