Comments (19)
@Caroga I am noticing that nginx_user
isn't getting set properly in the nginx.conf.j2
in RHEL. What version of Ansible are you using?
from ansible-role-nginx.
Here is an example output on RHEL. Notice it loads the OS specific variables correctly, and identifies the OS, but then nginx_user is set incorrectly
TASK [geerlingguy.nginx : Include OS-specific variables.] **********************
task path: /Users/redata425/Sites/devops/vsphere/consul/roles/geerlingguy.nginx/tasks/main.yml:3
ok: [mconsul] => {"ansible_facts": {"__nginx_user": "nginx", "nginx_conf_path": "/etc/nginx/conf.d", "nginx_default_vhost_path": "/etc/nginx/conf.d/default.conf", "nginx_vhost_path": "/etc/nginx/conf.d"}, "changed": false, "invocation": {"module_args": {"_raw_params": "RedHat.yml"}, "module_name": "include_vars"}}
TASK [geerlingguy.nginx : debug] ***********************************************
task path: /Users/redata425/Sites/devops/vsphere/consul/roles/geerlingguy.nginx/tasks/main.yml:6
ok: [mconsul] => {
"msg": "RedHat"
}
TASK [geerlingguy.nginx : Define nginx_user.] **********************************
task path: /Users/redata425/Sites/devops/vsphere/consul/roles/geerlingguy.nginx/tasks/main.yml:8
skipping: [mconsul] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}
TASK [geerlingguy.nginx : debug] ***********************************************
task path: /Users/redata425/Sites/devops/vsphere/consul/roles/geerlingguy.nginx/tasks/main.yml:13
ok: [mconsul] => {
"msg": "www-data"
}
from ansible-role-nginx.
@Caroga / @rossedman - This sounds like an upstream issue...
The reason that task is skipped is somewhere, upstream of this role (e.g. in your playbook, in an included vars file, in an inventory somewhere), the nginx_user
variable is being defined as www-data
.
This role does not define nginx_user
anywhere—not in defaults/main.yml
nor in vars/[os-family].yml
. It only defines __nginx_user: "www-data"
, so that task will only be skipped if the playbook/inventory/vars you have configured are explicitly setting:
nginx_user: www-data
from ansible-role-nginx.
@rossedman - You can even see that when the OS-specific variables are included—in your case RedHat.yml
, it's picking up "__nginx_user": "nginx"
, meaning it defaults to the user nginx
.
When it hits the Define nginx_user
task, it checks for whether nginx_user
is already defined, and it says that it is, so it skips the task and uses the value you set upstream (in your playbook or inventory).
from ansible-role-nginx.
@geerlingguy I thought the same thing, so I removed all roles and tasks and tried to only run this role. The only way I could fix it was explicitly setting nginx_user
in my playbook. I also did a find
and could not locate anywhere that www-data
was being set.
from ansible-role-nginx.
@rossedman - According to my local testing and also the automated tests for this role (https://travis-ci.org/geerlingguy/ansible-role-nginx/builds/104118511#L461), the task runs correctly when nginx_user
isn't defined, so could it be an external inventory source?
Are you using dynamic inventory, or are you using some sort of deployment system, or do you control a static inventory file and the playbook you're running end-to-end? Dynamic inventory might be set to inject an nginx_user
, and maybe it was set up originally to run on only Debian systems.
from ansible-role-nginx.
@geerlingguy Dynamic inventory but it shouldn't be setting any of these variables because its coming from Terraform and all that is being defined is ssh_user
and ip_address
. I believe you though! You are the man. I will look into my side some more. I'm also using Ansible 2.0 so I was worried there was a change in the way facts were set in playbooks from dynamically loaded files. I thought they changed the priority on how those loaded.
from ansible-role-nginx.
@rossedman - Hmm... I haven't messed with Terraform much, but I'm wondering if there's something upstream that's setting the variable or otherwise caching it. To test things out, try creating a local VM with Vagrant, and see if you can reproduce the issue; you can even use the LEMP example here for testing: https://github.com/geerlingguy/ansible-vagrant-examples/tree/master/lemp
from ansible-role-nginx.
I had the same problem when a different ansible role (let it be nameless for now) which first tried to pull in franklinkim's nginx first before this one. That role set a default value for "nginx_user" in its main.yml and from that moment on the variable remained set for even the successive (this) role. Not sure if this is related to inheritance upon dependencies. The problematic piece there was:
dependencies:
- { role: franklinkim.nginx, when: consul_install_nginx == true and ansible_os_family == "Debian" }
- { role: geerlingguy.nginx, when: consul_install_nginx == true and ansible_os_family == "RedHat" }
- { role: joshualund.golang, when: consul_install_consul_cli == true }
from ansible-role-nginx.
I have opened an issue for the consumer role that exhibits this issue (you can find a reference to it above;)).
from ansible-role-nginx.
@rbarabas This was the same role I was working with. I install my roles locally, so I removed the franklinkim one and I still had the problem. So I assumed it was here but maybe that isn't the case.
from ansible-role-nginx.
Are you sure the dependency wasn't pulled down again?
Btw, setting nginx_user explicitly in the play will have higher priority so that should work as a workaround but it may not be the best workaround when you have a hybrid set of servers. Also, if you rename the variable in default/main.yml of franklinkim's nginx you should be able to proceed without an error. At least I was able to.
from ansible-role-nginx.
@rbarabas I need to test again. It was pretty late when I did this, so I could be wrong. I did end up explicitly setting nginx_user
which solved the problem but my main concern was Ansible 2.0 changing how files were loaded. I thought I read something about how that had changed.
from ansible-role-nginx.
wow, i've been away for some days and really missed a good convo here!
Anyhow,
To see the roles and setup I've used: https://github.com/010PHP/010php.nl/tree/master/build
[caroga@lockhead ~]$ ansible --version
ansible 2.0.0.2
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
from ansible-role-nginx.
Also, I've tried placing it inside the playbook.yml, which should (as stated earlier) have a higher priority over the rest. https://github.com/010PHP/010php.nl/blob/master/build/playbook.yml
from ansible-role-nginx.
@Caroga Didn't mean to highjack your thread. Thought these issues were related. :)
from ansible-role-nginx.
Never a problem, all discussion helps!
from ansible-role-nginx.
This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!
Please read this blog post to see the reasons why I mark issues as stale.
from ansible-role-nginx.
This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.
from ansible-role-nginx.
Related Issues (20)
- how to run? HOT 2
- No errors reported when there is an error indeed HOT 2
- Using variables defining upstream servers HOT 3
- Extra modules are not loaded (nginx.conf template miss modules-enabled include) HOT 7
- Ubuntu PPA seems to not be maintained that much... switch to nginx packages? HOT 5
- Include tasks in one step HOT 2
- [Feature Request] Ability to not manage the nginx service HOT 2
- [Feature Request] Add possibility to anonymise logs HOT 3
- Nginx on Arch HOT 2
- nginx_listen_ipv6 is undefined in the vhost.js template HOT 4
- Support for separating core configuration and data ? HOT 1
- install nginx 1.20.1 on ubuntu to avoid remote code execution vulnerability HOT 2
- Installation does not work on CentOS 7 with python3 interpreter HOT 2
- Please add support for Elementary OS HOT 2
- Nginx isn't installed from nginx repo on Rocky 8 HOT 2
- Need to update cache even nginx are present HOT 2
- ppa:nginx is too old, Ubuntu 22.04 is not supported
- Redirect from http to https. HOT 3
- Docker service handling error HOT 2
- Override vars? HOT 1
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.