-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from hellofresh/feature/new_manage
Feature/new manage
- Loading branch information
Showing
13 changed files
with
297 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
--- | ||
driver : | ||
# TRAVIS: local | ||
# NO TRAVIS: vagrant | ||
name : <%= if ENV['TRAVIS'] then 'localhost' else 'vagrant' end %> | ||
driver : | ||
name : <%= if ENV['TRAVIS'] then 'localhost' else 'vagrant' end %> | ||
box : "ubuntu/trusty64" | ||
customize : | ||
cpus : 2 | ||
memory : 2048 | ||
|
||
provisioner: | ||
name : ansible_push | ||
verbose : "vvvv" | ||
ansible_config : "tests/ansible.cfg" | ||
idempotency_test : True | ||
# TRAVIS: True | ||
# NO TRAVIS: False | ||
sudo : <%= if ENV['TRAVIS'] then 'True' else 'False' end %> | ||
name : ansible_push | ||
verbose : "vvvv" | ||
ansible_config : "test/ansible.cfg" | ||
idempotency_test : True | ||
diff : True | ||
sudo : <%= if ENV['TRAVIS'] then 'True' else 'False' end %> | ||
raw_arguments : <%= if ENV['TRAVIS'] then '-c local' else '' end %> | ||
extra_vars : { 'kitchen_connection': '<%= if ENV["TRAVIS"] then "local" else "smart" end %>', 'kitchen_hosts': '<%= if ENV["TRAVIS"] then "localhost" else "all" end %>' } | ||
|
||
platforms: | ||
# travistravis | ||
- name : <%= if ENV['TRAVIS'] then 'travis' else 'ubuntu-14.04' end %> | ||
provisioner : | ||
raw_arguments : <%= if ENV['TRAVIS'] then '-c local' else '' end %> | ||
# Should be safily ignored by Travis since connection local | ||
driver : | ||
box : ubuntu/trusty64 | ||
customize : | ||
cpus : 2 | ||
memory : 2048 | ||
- name : "v1" | ||
provisioner : | ||
ansible_playbook_bin : "$(ansible-version path v1)ansible-playbook" | ||
|
||
- name : "v2" | ||
provisioner : | ||
ansible_playbook_bin : "$(ansible-version path v2)ansible-playbook" | ||
|
||
suites: | ||
- name : simple | ||
provisioner : | ||
playbook : "tests/application/simple.yml" | ||
extra_vars : { 'kitchen_connection': 'smart', 'kitchen_hosts': '<%= if ENV['TRAVIS'] then 'localhost' else 'all' end %>' } | ||
- name : simple | ||
provisioner : | ||
playbook : "test/integration/simple/simple.yml" | ||
|
||
- name : manage | ||
provisioner : | ||
playbook : "test/integration/manage/manage.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
source 'https://rubygems.org' | ||
|
||
|
||
group :development do | ||
gem 'test-kitchen' | ||
gem 'kitchen-vagrant' | ||
gem 'kitchen-ansiblepush' | ||
gem 'kitchen-localhost' | ||
gem 'net-ssh', '~> 2.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
|
||
- name: manage sites | Get current services | ||
shell: "ls *| sed 's/.conf//g'" | ||
changed_when: False | ||
args: | ||
chdir: "{{ nginx_etc }}/sites-enabled/" | ||
register: registered_nginx_sites | ||
|
||
- name: manage sites | Check if any services are old | ||
set_fact: | ||
current_filenames: "{{ nginx_site | map(attribute='file_name') | list + ['default'] }}" | ||
|
||
- name: manage sites | Check if any files needs to be removed | ||
set_fact: | ||
old_files: "{{ registered_nginx_sites.stdout_lines | difference(current_filenames) }}" | ||
|
||
- name: manage sites | List of files need to removed | ||
debug: | ||
var=old_files | ||
|
||
- name: manage sites | Ensure old services are removed | ||
file: | ||
path="{{ nginx_etc }}/sites-enabled/{{ item.0 }}{{ item.1 }}" | ||
state="absent" | ||
with_nested: | ||
- "{{ old_files }}" | ||
- [ "", ".conf"] | ||
notify: | ||
- reload nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[defaults] | ||
roles_path=../:../../:/spec/ | ||
# V2 | ||
callback_whitelist = changes | ||
|
||
ansible_managed=Ansible managed, Don't modify manually |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
- name : Manage | ||
hosts : "all" | ||
gather_facts : True | ||
become : True | ||
connection : "{{ kitchen_connection | default('local') }}" | ||
pre_tasks: | ||
- name: update apt | ||
apt: update_cache=yes cache_valid_time=3600 | ||
|
||
- name: One time tasks for testing | ||
shell: "mkdir -p /etc/nginx/sites-enabled/ && touch /etc/nginx/sites-enabled/remove_me.conf && touch /tmp/creates" | ||
args: | ||
creates: /tmp/creates | ||
|
||
- name: Create dir for content | ||
file: | ||
path="/nginx/{{ item }}" | ||
state=directory | ||
mode=0755 | ||
with_items: | ||
- test2 | ||
- test3 | ||
|
||
- name: Create content for test | ||
copy: | ||
content="Hello {{ item }}" | ||
dest="/nginx/{{ item }}/index.html" | ||
mode=0644 | ||
with_items: | ||
- test2 | ||
- test3 | ||
|
||
vars : | ||
nginx_manage_sites : True | ||
nginx_site : | ||
- file_name : "test2" | ||
blocks : | ||
- type : "server" | ||
index : "index.htm index.html" | ||
server_name : "localhost" | ||
listen : "1180" | ||
## Use josn | ||
location1 : { | ||
name: /, | ||
type: location, | ||
try_files: "$uri $uri/ =404", | ||
root: "/nginx/test2" | ||
} | ||
|
||
- file_name : "test3" | ||
blocks : | ||
- type : "server" | ||
index : "index.htm index.html" | ||
server_name : "localhost" | ||
listen : "1280" | ||
## Use josn | ||
location1 : { | ||
name: /, | ||
type: location, | ||
try_files: "$uri $uri/ =404", | ||
root: "/nginx/test3" | ||
} | ||
|
||
roles : | ||
- "ansible-nginx" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
require 'serverspec' | ||
|
||
# Required by serverspec | ||
set :backend, :exec | ||
|
||
describe 'Package Service' do | ||
describe package('nginx') do | ||
it { should be_installed } | ||
end | ||
|
||
describe service('nginx') do | ||
it { should be_enabled } | ||
it { should be_running } | ||
end | ||
|
||
describe port(1180) do | ||
it { should be_listening } | ||
end | ||
|
||
describe port(1280) do | ||
it { should be_listening } | ||
end | ||
|
||
end | ||
|
||
describe 'NGinx sites-enabled' do | ||
|
||
describe file('/etc/nginx/sites-enabled/default') do | ||
it { should be_symlink } | ||
it { should be_linked_to '/etc/nginx/sites-available/default' } | ||
end | ||
|
||
describe file('/etc/nginx/sites-enabled/test2.conf') do | ||
it { should be_symlink } | ||
it { should be_linked_to '/etc/nginx/sites-available/test2.conf' } | ||
end | ||
|
||
describe file('/etc/nginx/sites-enabled/test3.conf') do | ||
it { should be_symlink } | ||
it { should be_linked_to '/etc/nginx/sites-available/test3.conf' } | ||
end | ||
|
||
describe file('/etc/nginx/sites-enabled/remove_me.conf') do | ||
it { should_not exist } | ||
end | ||
|
||
end | ||
|
||
describe 'NGinx http content' do | ||
|
||
describe command "curl -s -L http://127.0.0.1:1180" do | ||
its(:exit_status) { should eq 0 } | ||
its(:stdout) { should match "Hello test2" } | ||
end | ||
|
||
describe command "curl -s -L http://127.0.0.1:1280" do | ||
its(:exit_status) { should eq 0 } | ||
its(:stdout) { should match "Hello test3" } | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'serverspec' | ||
|
||
# Required by serverspec | ||
set :backend, :exec | ||
|
||
describe 'Package Service' do | ||
describe package('nginx') do | ||
it { should be_installed } | ||
end | ||
|
||
describe service('nginx') do | ||
it { should be_enabled } | ||
it { should be_running } | ||
end | ||
|
||
describe port(1080) do | ||
it { should be_listening } | ||
end | ||
|
||
end | ||
|
||
describe 'NGinx sites-enabled' do | ||
|
||
describe file('/etc/nginx/sites-enabled/default') do | ||
it { should be_symlink } | ||
it { should be_linked_to '/etc/nginx/sites-available/default' } | ||
end | ||
|
||
describe file('/etc/nginx/sites-enabled/test.conf') do | ||
it { should be_symlink } | ||
it { should be_linked_to '/etc/nginx/sites-available/test.conf' } | ||
end | ||
|
||
end | ||
|
||
describe 'NGinx http content' do | ||
|
||
describe command "curl -s -L http://127.0.0.1:1080" do | ||
its(:exit_status) { should eq 0 } | ||
its(:stdout) { should match "Hello test1" } | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
- name : Simple | ||
hosts : "all" | ||
gather_facts : True | ||
become : True | ||
connection : "{{ kitchen_connection | default('local') }}" | ||
vars : | ||
nginx_site : | ||
- file_name : "test" | ||
blocks : | ||
- type : "server" | ||
index : "index.htm index.html" | ||
server_name : "localhost" | ||
listen : "1080" | ||
## Use josn | ||
location1 : { | ||
name: /, | ||
type: location, | ||
try_files: "$uri $uri/ /index.html", | ||
root: "/nginx/test1/" | ||
} | ||
pre_tasks: | ||
- name: update apt | ||
apt: update_cache=yes cache_valid_time=3600 | ||
|
||
- name: Create dir for content | ||
file: | ||
path="/nginx/{{ item }}" | ||
state=directory | ||
mode=0755 | ||
with_items: | ||
- test1 | ||
|
||
- name: Create content for test | ||
copy: | ||
content="Hello {{ item }}" | ||
dest="/nginx/{{ item }}/index.html" | ||
mode=0644 | ||
with_items: | ||
- test1 | ||
|
||
roles : | ||
- "ansible-nginx" | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.