Comments (11)
Hi @nschloe ,
You can use multiple time the role in a playbook.
For example :
- role: nginx // for the packages installation
nginx_sites: [] // you can declare your default pages
- phpmyadmin
- role: nginx
nginx_installation_type: "configuration-only" // this line is not mandatory, it's a optimisation
nginx_sites:
phpmyadmin: "{{phpmyadmin_nginx_config}}"
Sites name and config name need to have different name between several usage.
Best regards,
Julien
from ansible-role-nginx.
We have two roles webserver
and jenkins
and both should add a vhost configuration for nginx. In a role's tasks/main.yml
, your proposed code doesn't work. Any idea how to get this running? Thx!
from ansible-role-nginx.
@andrenarchy can you give more details on what doesn't work ?
from ansible-role-nginx.
I don't see how a role (nginx
) can be called from the tasks/main.yml
of another role.
I guess we can only call a role from another role with dependencies
in meta/main.yml
. In our case, the roles webserver
and jenkins
depend on nginx:
# roles/webserver/meta/main.yml
dependencies:
- role: jdauphant.nginx
nginx_installation_type: "configuration-only"
# global nginx params
nginx_http_params:
- sendfile "on"
# ...
nginx_sites:
main_https:
# listen ...
# roles/jenkins/meta/main.yml
dependencies:
- role: jdauphant.nginx
nginx_installation_type: "configuration-only"
nginx_sites:
jenkins_https:
# listen ...
If jenkins
is called after webserver
, it overwrites the nginx.conf
with the default config provided in https://github.com/jdauphant/ansible-role-nginx/blob/master/defaults/main.yml#L36. It would be nice to put the nginx
role into a mode where only the provided keys are processed. Is this possible?
from ansible-role-nginx.
@andrenarchy I see. You can use nginx_config variable :
dependencies:
- role: jdauphant.nginx
nginx_installation_type: "configuration-only"
# global nginx params
nginx_http_params: {}
nginx_configs:
webserver:
- sendfile "on"
# ...
nginx_sites:
main_https:
# listen ...
(Maybe, we should deprecated nginx_http_params and use nginx_config with a default config)
@nschloe @andrenarchy I have add "allow_duplicates: yes" in the last version 1.7.1
Best regards,
Julien
from ansible-role-nginx.
So your idea is to trim nginx.conf
to the include statements, right? Sounds like a good plan! But then: why differentiate between conf.d and site includes at all? Don't they all end up in the http block?
Thx for adding allow_duplicates
! :-)
from ansible-role-nginx.
nginx_sites are directly included in "server {}" block, nginx_config are not.
nginx_sites are specific configuration, nginx_config are generic configuration.
This force to separate things in logical and more maintainable way.
from ansible-role-nginx.
@jdauphant Your proposed config works like a charm (after I realized that nginx_config
should be nginx_configs
). Thanks!
In order to reduce the overhead for multiple calls to the module, I overwrite the defaults in group_vars/all
with:
nginx_installation_type: "configuration-only"
nginx_http_params: {}
nginx_configs: {}
nginx_sites: {}
Maybe this is of interest for others.
Anyway, I think this issue can be closed. :)
from ansible-role-nginx.
Ah, sorry for the mistake in the name. I have corrected that.
from ansible-role-nginx.
@nschloe I have close the issue, if we have some problem don't hesitate to comments.
from ansible-role-nginx.
Everything working as expected! Thanks!
from ansible-role-nginx.
Related Issues (20)
- Add installation from sources HOT 1
- remove a site is not taken in consideration HOT 2
- Ansible error HOT 1
- Change nginx user HOT 4
- disable default config HOT 5
- Error in handlers/main.yml HOT 1
- issue when adding header parameter with ";" HOT 1
- Does this role need run as root? HOT 1
- amplify.api_key variable does not exist HOT 1
- add_header X-XSS-Protection is causing problems HOT 2
- Nginx didn't start on install
- v2.16 missing on https://galaxy.ansible.com/jdauphant/nginx HOT 1
- Warning, Duplicate When Key HOT 5
- Allow for no default config to be generated HOT 3
- Configuring modules is currently limited to Centos/RHEL only HOT 1
- Missing mime.types file plus /etc/mime.types idea HOT 2
- Adhere to ansible-lint rules HOT 2
- Travis job is still on python 2.7 HOT 2
- Debian 12 (python3) support
- version > v2.21.2 are not avaiable via ansible-galaxy install command
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible-role-nginx.