Skip to content

Commit 1146284

Browse files
committed
Merge pull request #4 from AutomationWithAnsible/feature/cleanup
Feature/cleanup
2 parents ca7097d + b48f356 commit 1146284

File tree

16 files changed

+199
-87
lines changed

16 files changed

+199
-87
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.kitchen

.kitchen.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
driver :
3+
# TRAVIS: local
4+
# NO TRAVIS: vagrant
5+
name : <%= if ENV['TRAVIS'] then 'localhost' else 'vagrant' end %>
6+
7+
provisioner:
8+
name : ansible_push
9+
verbose : "vvvv"
10+
ansible_config : "tests/ansible.cfg"
11+
idempotency_test : True
12+
# TRAVIS: True
13+
# NO TRAVIS: False
14+
sudo : <%= if ENV['TRAVIS'] then 'True' else 'False' end %>
15+
16+
platforms:
17+
# travistravis
18+
- name : <%= if ENV['TRAVIS'] then 'travis' else 'ubuntu-14.04' end %>
19+
provisioner :
20+
raw_arguments : <%= if ENV['TRAVIS'] then '-c local' else '' end %>
21+
# Should be safily ignored by Travis since connection local
22+
driver :
23+
box : ubuntu/trusty64
24+
customize :
25+
cpus : 2
26+
memory : 2048
27+
28+
suites:
29+
- name : simple
30+
provisioner :
31+
playbook : "tests/application/simple.yml"
32+
extra_vars : { 'kitchen_connection': 'smart', 'kitchen_hosts': '<%= if ENV['TRAVIS'] then 'localhost' else 'all' end %>' }
33+

.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
language: python
3+
python: "2.7"
4+
5+
before_install:
6+
# Make sure everything's up to date.
7+
- sudo apt-get update -qq
8+
- sudo apt-get install -qq python-apt python-pycurl git python-pip ruby ruby-dev build-essential autoconf
9+
- gem install bundler
10+
11+
install:
12+
- sudo pip install ansible
13+
14+
script:
15+
- ansible --version
16+
- export TRAVIS=True
17+
- bundle install
18+
- bundle exec kitchen test travis
19+
20+
after_success:
21+
- echo "Success"

Gemfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
source 'https://rubygems.org'
2+
3+
4+
group :development do
5+
gem 'test-kitchen'
6+
gem 'kitchen-vagrant'
7+
gem 'kitchen-ansiblepush'
8+
gem 'kitchen-localhost'
9+
end

defaults/main.yml

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
---
2-
nginx_etc : "/etc/nginx/"
3-
nginx_default_root : "/usr/share/nginx/html" # Will only work for ubuntu
4-
nginx_max_clients : 512
5-
nginx_install_repo : "ubuntu" # Options: ["nginx", "ubuntu"]
6-
nginx_apt_state : "present" # Options: ["latest", "present"]
2+
nginx_etc : "/etc/nginx/"
3+
nginx_default_root : "/usr/share/nginx/html" # Will only work for ubuntu
4+
nginx_max_clients : 512
5+
nginx_install_repo : "ubuntu" # Options: ["nginx", "ubuntu"]
6+
nginx_apt_state : "present" # Options: ["latest", "present"]
77

8-
nginx_http_params:
9-
sendfile: "on"
10-
tcp_nopush: "on"
11-
tcp_nodelay: "on"
12-
keepalive_timeout: "65"
13-
access_log: "/var/log/nginx/access.log"
14-
error_log: "/var/log/nginx/error.log"
8+
nginx_http_params :
9+
sendfile : "on"
10+
tcp_nopush : "on"
11+
tcp_nodelay : "on"
12+
keepalive_timeout : "65"
13+
access_log : "/var/log/nginx/access.log"
14+
error_log : "/var/log/nginx/error.log"
1515

16-
nginx_site :
17-
- file_name : "test"
18-
blocks :
19-
- type : "server"
20-
index : "index.html index.htm"
21-
server_name : localhost
22-
listen : 80
16+
nginx_site :
17+
- file_name : "test"
18+
blocks :
19+
- type : "server"
20+
index : "index.html index.htm"
21+
server_name : localhost
22+
listen : 80
2323
## Use josn
24-
location1 : {
25-
name: /,
26-
type: location,
27-
try_files: "$uri $uri/ /index.html",
28-
root: "{{ nginx_default_root }}"
29-
}
24+
location1 : {
25+
name: /,
26+
type: location,
27+
try_files: "$uri $uri/ /index.html",
28+
root: "{{ nginx_default_root }}"
29+
}
3030
## Use yaml
31-
location2 :
32-
name : /doc/,
33-
type : location
34-
alias : "/usr/share/doc/"
35-
autoindex : "on"
36-
allow : "127.0.0.1"
37-
deny : "all"
31+
location2 :
32+
name : /doc/
33+
type : location
34+
alias : "/usr/share/doc/"
35+
autoindex : "on"
36+
allow : "127.0.0.1"
37+
deny : "all"
3838

handlers/main.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
---
2+
3+
- name: check restart nginx
4+
command:
5+
nginx -t -c "{{ nginx_etc }}/nginx.conf"
6+
changed_when: True
7+
notify:
8+
- restart nginx
9+
10+
- name: check reload nginx
11+
command:
12+
nginx -t -c "{{ nginx_etc }}/nginx.conf"
13+
changed_when: True
14+
notify:
15+
- reload nginx
16+
217
- name: restart nginx
318
service:
4-
name=nginx
5-
state=restarted
19+
name=nginx
20+
state=restarted
621

722
- name: reload nginx
823
service:
9-
name=nginx
10-
state=reloaded
24+
name=nginx
25+
state=reloaded

meta/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ galaxy_info:
2222
- saucy
2323
categories:
2424
- web
25-
dependencies: []
26-
25+
dependencies: []

tasks/common.yml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
- name: common | Create the directories for site specific configurations
44
file:
5-
path="{{nginx_etc}}/{{item}}"
5+
path="{{ nginx_etc }}/{{ item }}"
66
state=directory
77
owner=root
88
group=root
@@ -13,49 +13,49 @@
1313

1414
- name: common | Copy the nginx default configuration file
1515
template:
16-
src=default.j2
17-
dest="{{ nginx_etc }}/sites-available/default.conf"
16+
src=default.j2
17+
dest="{{ nginx_etc }}/sites-available/default.conf"
1818

1919
- name: common |Copy the nginx default site configuration file
2020
template:
21-
src=default.j2
22-
dest="{{nginx_etc}}/sites-available/default"
21+
src=default.j2
22+
dest="{{ nginx_etc }}/sites-available/default"
2323

2424
- name: common | Create the link for site enabled specific configurations
2525
file:
26-
path="{{nginx_etc}}/sites-enabled/default"
27-
state=link
28-
src="{{nginx_etc}}/sites-available/default"
26+
path="{{ nginx_etc }}/sites-enabled/default"
27+
state=link
28+
src="{{ nginx_etc }}/sites-available/default"
2929

3030
- name: common | Create the configuration files for nginx
3131
template:
32-
src=site.j2
33-
dest="{{nginx_etc}}/sites-available/{{item.file_name}}.conf"
32+
src=site.j2
33+
dest="{{ nginx_etc }}/sites-available/{{ item.file_name }}.conf"
3434
with_items: nginx_site
35-
when: nginx_site |lower != 'none'
35+
when: nginx_site | lower != 'none'
3636
notify:
37-
- reload nginx
37+
- check reload nginx
3838

3939
## TODO: Add conidition to disable/enable sites
4040
- name: Create the link for site enabled specific configurations
4141
file:
42-
path="{{nginx_etc}}/sites-enabled/{{item.file_name}}.conf"
42+
path="{{ nginx_etc }}/sites-enabled/{{ item.file_name }}.conf"
4343
state=link
44-
src="{{nginx_etc}}/sites-available/{{item.file_name}}.conf"
44+
src="{{ nginx_etc }}/sites-available/{{ item.file_name }}.conf"
4545
with_items: nginx_site
4646
notify:
47-
- reload nginx
47+
- check reload nginx
4848

4949
- name: common | Copy the nginx main configuration file
5050
template:
51-
src=nginx.conf.j2
52-
dest="{{nginx_etc}}/nginx.conf"
53-
validate='nginx -t -c %s'
51+
src=nginx.conf.j2
52+
dest="{{ nginx_etc }}/nginx.conf"
53+
validate='nginx -t -c %s'
5454
notify:
55-
- restart nginx
55+
- check restart nginx
5656

5757
- name: common | start the nginx service
5858
service:
59-
name=nginx
60-
state=started
61-
enabled=yes
59+
name=nginx
60+
state=started
61+
enabled=yes

tasks/nginx_debian.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
- name: nginx_debian | Install the nginx packages
1515
apt:
16-
name={{ item }}
17-
state={{nginx_apt_state}}
16+
name="{{ item }}"
17+
state="{{nginx_apt_state}}"
1818
with_items: ubuntu_pkg
19-
environment: env
19+
environment: "{{ env }}"
2020
when: ansible_os_family == "Debian"

tasks/nginx_redhat.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424

2525
- name: nginx_redhat | Install the nginx packages
2626
yum:
27-
name={{ item }}
27+
name="{{ item }}"
2828
state=present
2929
with_items: redhat_pkg

0 commit comments

Comments
 (0)