Skip to content

Commit

Permalink
Merge pull request #2 from solutionDrive/change-travis
Browse files Browse the repository at this point in the history
Change travis
  • Loading branch information
michz authored Jul 4, 2018
2 parents 075889e + 2035d32 commit 35decc5
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 51 deletions.
45 changes: 26 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
---
language: python
python: "2.7"
services: docker

# Use the new container infrastructure
sudo: false
env:
- distro: ubuntu1804
- distro: ubuntu1604
- distro: ubuntu1404
- distro: debian9
- distro: debian8

# Install ansible
addons:
apt:
packages:
- python-pip
before_script:
# Check for correct eof newlines
- wget -O ${PWD}/tests/check-eof-newline.sh https://gist.github.com/sd-lueckel/fd262b2570c270bf8695ed6bdd388727/raw/
- chmod +x ${PWD}/tests/check-eof-newline.sh
- ${PWD}/tests/check-eof-newline.sh

install:
# Install ansible
- pip install ansible
# Check for line endings
- wget -O ${PWD}/tests/check-line-endings.sh https://gist.github.com/sd-lueckel/1114f569d0a60f3447b28cc7c82f8fd4/raw/
- chmod +x ${PWD}/tests/check-line-endings.sh
- ${PWD}/tests/check-line-endings.sh

# Check ansible version
- ansible --version

# Create ansible.cfg with correct roles_path
- printf '[defaults]\nroles_path=../' >ansible.cfg
# Check for trailing whitespaces
- wget -O ${PWD}/tests/check-trailing_whitespaces.sh https://gist.github.com/sd-lueckel/335ef1b6a9e996b384748a3e1cf15b61/raw/
- chmod +x ${PWD}/tests/check-trailing_whitespaces.sh
- ${PWD}/tests/check-trailing_whitespaces.sh

script:
# Basic role syntax check
- ansible-playbook tests/test.yml -i tests/inventory --syntax-check
# Download test shim.
- wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
- chmod +x ${PWD}/tests/test.sh

# Run tests.
- ${PWD}/tests/test.sh

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
13 changes: 10 additions & 3 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
galaxy_info:
role_name: deployment
author: solutionDrive GmbH
description: Role to prepare servers for deployment
company: solutionDrive GmbH
Expand All @@ -7,9 +8,15 @@ galaxy_info:
min_ansible_version: 1.2

platforms:
- name: Ubuntu
versions:
- all
- name: Ubuntu
versions:
- bionic
- xenial
- trusty
- name: Debian
versions:
- stretch
- jessie

galaxy_tags:
- server
Expand Down
17 changes: 8 additions & 9 deletions tasks/authentication.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
owner: "{{ deployment_ssh_user }}"
group: www-data
mode: u=r,g=,o=
become: yes

- name: Copy Public Deployment-Key
copy:
Expand All @@ -15,15 +14,13 @@
owner: "{{ deployment_ssh_user }}"
group: www-data
mode: u=rw,g=rw,o=r
become: yes

- name: "create {{ deployment_auth_destination_path_ssh_user }} if it does not exist"
file:
state: directory
path: "{{ deployment_auth_destination_path_ssh_user }}"
owner: "{{ deployment_ssh_user }}"
group: www-data
become: yes

- name: "Store Toran-Authentication for composer installation for User {{ deployment_ssh_user }}"
copy:
Expand All @@ -32,7 +29,6 @@
owner: "{{ deployment_ssh_user }}"
group: www-data
mode: 0600
become: yes
when: deployment_install_composer_auth

- name: Copy Private Deployment-Key to root user if configured
Expand All @@ -42,7 +38,6 @@
owner: root
group: root
mode: u=r,g=,o=
become: yes
when: deployment_key_to_root_user
notify: remove key from root

Expand All @@ -53,18 +48,24 @@
owner: root
group: root
mode: u=rw,g=r,o=r
become: yes
when: deployment_key_to_root_user
notify: remove key from root

- name: "Create /root/.composer/ path if it does not exists"
file:
state: directory
path: /root/.composer/
owner: root
group: root
when: deployment_install_composer_auth

- name: Store Toran-Authentication for composer installation for User root
copy:
src: "{{ deployment_src_path }}{{ deployment_name_of_toran_auth_file }}"
dest: /root/.composer/auth.json
owner: root
group: root
mode: 0600
become: yes
when: deployment_install_composer_auth

- name: Copy Private Deployment-Key to www-data user
Expand All @@ -74,7 +75,6 @@
owner: www-data
group: www-data
mode: u=r,g=,o=
become: yes

- name: Copy Public Deployment-Key to www-data user
copy:
Expand All @@ -83,4 +83,3 @@
owner: root
group: root
mode: u=rw,g=r,o=r
become: yes
3 changes: 0 additions & 3 deletions tasks/filesystem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
state: directory
owner: www-data
group: www-data
become: yes

- name: Create .ssh-Directory for root if configured
file:
path: /root/.ssh
state: directory
owner: root
group: root
become: yes
when: deployment_key_to_root_user

- name: "Create bin-directory for user {{ deployment_ssh_user }}"
Expand All @@ -22,4 +20,3 @@
state: directory
owner: "{{ deployment_ssh_user }}"
group: www-data
become: yes
3 changes: 0 additions & 3 deletions tasks/git.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@
src='gitconfig'
dest='/etc/gitconfig'
force=no
become: yes


12 changes: 6 additions & 6 deletions tasks/known_hosts.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
---
- name: Ensure global known_hosts files exist
file:
path: "{{ deployment_global_ssh_known_hosts_file }}"
state: touch
mode: 0644

- name: Add bitbucket.org to global known_hosts
lineinfile:
path: "{{ deployment_global_ssh_known_hosts_file }}"
line: "{{ deployment_bitbucket_public_host_key }}"
create: yes
mode: 0644
state: present

- name: Add packagist.org to global known_hosts
lineinfile:
path: "{{ deployment_global_ssh_known_hosts_file }}"
line: "{{ deployment_packagist_public_host_key }}"
create: yes
mode: 0644
state: present

- name: Add github.com to global known_hosts
lineinfile:
path: "{{ deployment_global_ssh_known_hosts_file }}"
line: "{{ deployment_github_public_host_key }}"
create: yes
mode: 0644
state: present
5 changes: 0 additions & 5 deletions tasks/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
group:
name: wheel
state: present
become: yes

- name: Ensure 'wheel'-group has passwordless sudo
lineinfile:
Expand All @@ -12,20 +11,16 @@
regexp: '^%wheel'
line: '%wheel ALL=(ALL) NOPASSWD: ALL'
validate: visudo -cf %s
become: yes

- name: "Create User {{ deployment_ssh_user }}"
user:
name: "{{ deployment_ssh_user }}"
group: "{{ deployment_ssh_user_group }}"
groups: www-data,wheel
#shell: "{{ deployment_ssh_user_shell }}"
become: yes

- name: "Create .ssh-Directory for {{ deployment_ssh_user }}"
file:
path: "{{ deployment_key_destination_path_ssh_user }}"
state: directory
owner: "{{ deployment_ssh_user }}"
group: www-data
become: yes
3 changes: 3 additions & 0 deletions tests/files/auth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"Authentication": "I am root!"
}
2 changes: 2 additions & 0 deletions tests/files/id_rsa
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This is a private key file!
It is absolutly secure :D
2 changes: 2 additions & 0 deletions tests/files/id_rsa.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This is a public key file!
It is ok to show it to the world :D
15 changes: 12 additions & 3 deletions tests/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
---
- hosts: localhost
remote_user: root
- hosts: all
become: yes

vars:
deployment_key_remove_key_from_root: false

pre_tasks:
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'

roles:
- solutiondrive.deployment
- role_under_test

0 comments on commit 35decc5

Please sign in to comment.