This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 302
Some cleanups, clearer syntax, refactor variables, drop selinux and epel (let other roles do that) #55
Closed
Closed
Some cleanups, clearer syntax, refactor variables, drop selinux and epel (let other roles do that) #55
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fbff7c9
some cleanups, use a clearer yaml syntax, rename a variable not prefi…
1b9a0ad
put packages names in variables, and put variables in files used by i…
d24763c
simple packages installation.
423311c
truly disable/enable official repositories
2bde028
fix repository setup
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,8 +1,12 @@ | ||
--- | ||
- name: restart nginx | ||
service: name={{ nginx_service_name }} state=restarted | ||
service: | ||
name: "{{ nginx_service_name }}" | ||
state: restarted | ||
when: nginx_installation_type in nginx_installation_types_using_service and nginx_daemon_mode == "on" | ||
|
||
- name: reload nginx | ||
service: name={{ nginx_service_name }} state=reloaded | ||
service: | ||
name: "{{ nginx_service_name }}" | ||
state: reloaded | ||
when: nginx_installation_type in nginx_installation_types_using_service and nginx_daemon_mode == "on" |
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,53 +1,93 @@ | ||
--- | ||
- name: Create the directories for site specific configurations | ||
file: path={{nginx_conf_dir}}/{{ item }} state=directory owner=root group={{nginx_group}} mode=0755 | ||
- name: "Create the directories for site specific configurations" | ||
file: | ||
group: "{{ nginx_group }}" | ||
mode: 493 | ||
owner: root | ||
path: "{{nginx_conf_dir}}/{{ item }}" | ||
state: directory | ||
tags: | ||
- configuration | ||
- nginx | ||
with_items: | ||
- "sites-available" | ||
- "sites-enabled" | ||
- "auth_basic" | ||
- "conf.d" | ||
tags: [configuration,nginx] | ||
- sites-available | ||
- sites-enabled | ||
- auth_basic | ||
- conf.d | ||
|
||
- name: Ensure log directory exist | ||
file: path={{ nginx_log_dir }} state=directory owner={{nginx_user}} group={{nginx_group}} mode=0755 | ||
tags: [configuration,nginx] | ||
- name: "Ensure log directory exist" | ||
file: | ||
group: "{{ nginx_group }}" | ||
mode: 493 | ||
owner: "{{ nginx_user }}" | ||
path: "{{ nginx_log_dir }}" | ||
state: directory | ||
tags: | ||
- configuration | ||
- nginx | ||
|
||
- name: Copy the nginx configuration file | ||
template: src=nginx.conf.j2 dest={{nginx_conf_dir}}/nginx.conf | ||
- name: "Copy the nginx configuration file" | ||
template: | ||
dest: "{{ nginx_conf_dir }}/nginx.conf" | ||
src: nginx.conf.j2 | ||
notify: | ||
- restart nginx | ||
tags: [configuration,nginx] | ||
- "restart nginx" | ||
tags: | ||
- configuration | ||
- nginx | ||
|
||
- name: Ensure auth_basic files created | ||
template: src=auth_basic.j2 dest={{nginx_conf_dir}}/auth_basic/{{ item }} owner=root group={{nginx_group}} mode=0750 | ||
- name: "Ensure auth_basic files created" | ||
template: | ||
src: auth_basic.j2 | ||
dest: "{{nginx_conf_dir}}/auth_basic/{{ item }}" | ||
owner: root | ||
group: "{{nginx_group}}" | ||
mode: 0750 | ||
with_items: nginx_auth_basic_files.keys() | ||
tags: [configuration,nginx] | ||
tags: | ||
- configuration | ||
- nginx | ||
|
||
- name: Create the configurations for sites | ||
template: src=site.conf.j2 dest={{nginx_conf_dir}}/sites-available/{{ item }}.conf | ||
- name: "Create the configurations for sites" | ||
template: | ||
src: site.conf.j2 | ||
dest: "{{nginx_conf_dir}}/sites-available/{{ item }}.conf" | ||
with_items: nginx_sites.keys() | ||
notify: | ||
- restart nginx | ||
tags: [configuration,nginx] | ||
notify: | ||
- "restart nginx" | ||
tags: | ||
- configuration | ||
- nginx | ||
|
||
- name: Create links for sites-enabled | ||
file: state=link src={{nginx_conf_dir}}/sites-available/{{ item }}.conf dest={{nginx_conf_dir}}/sites-enabled/{{ item }}.conf | ||
- name: "Create links for sites-enabled" | ||
file: | ||
state: link | ||
src: "{{ nginx_conf_dir }}/sites-available/{{ item }}.conf" | ||
dest: "{{ nginx_conf_dir }}/sites-enabled/{{ item }}.conf" | ||
with_items: nginx_sites.keys() | ||
notify: | ||
- reload nginx | ||
tags: [configuration,nginx] | ||
- "reload nginx" | ||
tags: | ||
- configuration | ||
- nginx | ||
|
||
- name: Create the configurations for independent config file | ||
template: src=config.conf.j2 dest={{nginx_conf_dir}}/conf.d/{{ item }}.conf | ||
- name: "Create the configurations for independent config file" | ||
template: | ||
src: config.conf.j2 | ||
dest: "{{nginx_conf_dir}}/conf.d/{{ item }}.conf" | ||
with_items: nginx_configs.keys() | ||
notify: | ||
- reload nginx | ||
tags: [configuration,nginx] | ||
- "reload nginx" | ||
tags: | ||
- configuration | ||
- nginx | ||
|
||
- name: Check nginx syntax of configuration files | ||
shell: "{{ nginx_binary_name }} -t" | ||
register: result | ||
- name: "Check nginx syntax of configuration files" | ||
always_run: true | ||
changed_when: "result.rc != 0" | ||
always_run: yes | ||
register: result | ||
shell: "{{ nginx_binary_name }} -t" | ||
tags: | ||
- configuration | ||
- nginx | ||
when: nginx_installation_type in nginx_installation_types_using_service | ||
tags: [configuration,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 |
---|---|---|
@@ -1,29 +1,4 @@ | ||
--- | ||
- name: Install the selinux python module | ||
yum: name=libselinux-python state=present | ||
when: ansible_os_family == "RedHat" | ||
tags: [packages,nginx] | ||
|
||
- name: Install the epel packages | ||
yum: name=epel-release state=present | ||
when: nginx_is_el|bool | ||
tags: [packages,nginx] | ||
|
||
- name: Install the nginx packages | ||
yum: name={{ item }} state=present disablerepo='*' enablerepo={{ "nginx," if nginx_official_repo else "" }}{{ yum_epel_repo }},{{ yum_base_repo }} | ||
with_items: nginx_redhat_pkg | ||
when: nginx_is_el|bool | ||
tags: [packages,nginx] | ||
|
||
- name: Install the nginx packages | ||
yum: name={{ item }} state=present | ||
with_items: nginx_redhat_pkg | ||
when: ansible_os_family == "RedHat" and not nginx_is_el|bool | ||
tags: [packages,nginx] | ||
|
||
- name: Install the nginx packages | ||
apt: name={{ item }} state=present | ||
with_items: nginx_ubuntu_pkg | ||
environment: env | ||
when: ansible_os_family == "Debian" | ||
tags: [packages,nginx] | ||
- name: Install nginx packages | ||
action: "{{ ansible_pkg_mgr }} name={{ item }} state=present" | ||
with_items: nginx_packages | ||
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,16 +1,27 @@ | ||
--- | ||
- include_vars: "{{ ansible_os_family }}.yml" | ||
|
||
- include: nginx-official-repo.yml | ||
when: nginx_official_repo == True | ||
|
||
- include: installation.packages.yml | ||
when: nginx_installation_type == "packages" | ||
|
||
- include: remove-defaults.yml | ||
when: not keep_only_specified | ||
when: not nginx_keep_only_specified | ||
|
||
- include: remove-extras.yml | ||
when: keep_only_specified | ||
when: nginx_keep_only_specified | ||
|
||
- include: remove-unwanted.yml | ||
|
||
- include: configuration.yml | ||
|
||
- name: Start the nginx service | ||
service: name={{ nginx_service_name }} state=started enabled=yes | ||
service: | ||
name: "{{ nginx_service_name }}" | ||
state: started | ||
enabled: yes | ||
when: nginx_installation_type in nginx_installation_types_using_service and nginx_daemon_mode == "on" | ||
tags: [service,nginx] | ||
tags: | ||
- service | ||
- 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 |
---|---|---|
@@ -1,18 +1,34 @@ | ||
--- | ||
- name: Ensure APT official nginx key | ||
apt_key: url=http://nginx.org/keys/nginx_signing.key | ||
tags: [packages,nginx] | ||
apt_key: | ||
url: http://nginx.org/keys/nginx_signing.key | ||
when: ansible_os_family == 'Debian' | ||
tags: | ||
- packages | ||
- nginx | ||
|
||
- name: Ensure APT official nginx repository | ||
apt_repository: repo="deb http://nginx.org/packages/{{ ansible_distribution|lower }}/ {{ ansible_distribution_release }} nginx" | ||
tags: [packages,nginx] | ||
apt_repository: | ||
repo: "deb http://nginx.org/packages/{{ ansible_distribution|lower }}/{{ ansible_distribution_release }} nginx" | ||
state: "{% if nginx_official_repo %}present{% else %}absent{% endif %}" | ||
tags: | ||
- packages | ||
- nginx | ||
when: ansible_os_family == 'Debian' | ||
|
||
- name: Ensure RPM official nginx key | ||
rpm_key: key=http://nginx.org/keys/nginx_signing.key | ||
when: ansible_os_family == 'RedHat' | ||
rpm_key: | ||
key: http://nginx.org/keys/nginx_signing.key | ||
when: ansible_os_family == 'RedHat' and nginx_official_repo | ||
|
||
- name: Ensure YUM official nginx repository | ||
template: src=nginx.repo.j2 dest=/etc/yum.repos.d/nginx.repo | ||
when: ansible_os_family == 'RedHat' | ||
template: | ||
src: nginx.repo.j2 | ||
dest: /etc/yum.repos.d/nginx.repo | ||
when: ansible_os_family == 'RedHat' and nginx_official_repo | ||
|
||
- name: Ensure YUM official nginx repository is absent | ||
file: | ||
path: /etc/yum.repos.d/nginx.repo | ||
state: absent | ||
when: not nginx_official_repo |
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,15 +1,22 @@ | ||
--- | ||
- name: Disable the default site | ||
file: path={{nginx_conf_dir}}/sites-enabled/default state=absent | ||
file: | ||
path: "{{nginx_conf_dir}}/sites-enabled/default" | ||
state: absent | ||
notify: | ||
- reload nginx | ||
tags: [configuration,nginx] | ||
- reload nginx | ||
tags: | ||
- configuration | ||
- nginx | ||
|
||
- name: Remove the default configuration | ||
file: path={{nginx_conf_dir}}/conf.d/default.conf state=absent | ||
when: > | ||
'default' not in nginx_configs.keys() | ||
file: | ||
path: "{{nginx_conf_dir}}/conf.d/default.conf" | ||
state: absent | ||
when: '"default" not in nginx_configs.keys()' | ||
notify: | ||
- reload nginx | ||
tags: [configuration,nginx] | ||
- reload nginx | ||
tags: | ||
- configuration | ||
- 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 |
---|---|---|
@@ -1,31 +1,43 @@ | ||
--- | ||
- name: Find enabled sites | ||
shell: ls -1 {{nginx_conf_dir}}/sites-enabled | ||
shell: "ls -1 {{ nginx_conf_dir }}/sites-enabled" | ||
register: enabled_sites | ||
changed_when: False | ||
tags: [configuration,nginx] | ||
tags: | ||
- configuration | ||
- nginx | ||
|
||
- name: Disable unmanaged sites | ||
file: path={{nginx_conf_dir}}/sites-enabled/{{ item }} state=absent | ||
file: | ||
path: "{{nginx_conf_dir}}/sites-enabled/{{ item }}" | ||
state: absent | ||
with_items: enabled_sites.stdout_lines | ||
# 'item.conf' => 'item' | ||
when: item[:-5] not in nginx_sites.keys() | ||
notify: | ||
- reload nginx | ||
tags: [configuration,nginx] | ||
- reload nginx | ||
tags: | ||
- configuration | ||
- nginx | ||
|
||
- name: Find config files | ||
shell: ls -1 {{nginx_conf_dir}}/conf.d | ||
register: config_files | ||
changed_when: False | ||
tags: [configuration,nginx] | ||
tags: | ||
- configuration | ||
- nginx | ||
|
||
- name: Remove unmanaged config files | ||
file: name={{nginx_conf_dir}}/conf.d/{{ item }} state=absent | ||
file: | ||
name: "{{nginx_conf_dir}}/conf.d/{{ item }}" | ||
state: absent | ||
with_items: config_files.stdout_lines | ||
# 'item.conf' => 'item' | ||
when: item[:-5] not in nginx_configs.keys() | ||
notify: | ||
- reload nginx | ||
tags: [configuration,nginx] | ||
- reload nginx | ||
tags: | ||
- configuration | ||
- nginx | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add newline ;)