Giter Site home page Giter Site logo

Comments (19)

rossedman avatar rossedman commented on May 18, 2024

@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.

rossedman avatar rossedman commented on May 18, 2024

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.

geerlingguy avatar geerlingguy commented on May 18, 2024

@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.

geerlingguy avatar geerlingguy commented on May 18, 2024

@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.

rossedman avatar rossedman commented on May 18, 2024

@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.

geerlingguy avatar geerlingguy commented on May 18, 2024

@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.

rossedman avatar rossedman commented on May 18, 2024

@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.

geerlingguy avatar geerlingguy commented on May 18, 2024

@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.

rbarabas avatar rbarabas commented on May 18, 2024

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.

rbarabas avatar rbarabas commented on May 18, 2024

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.

rossedman avatar rossedman commented on May 18, 2024

@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.

rbarabas avatar rbarabas commented on May 18, 2024

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.

rossedman avatar rossedman commented on May 18, 2024

@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.

Caroga avatar Caroga commented on May 18, 2024

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.

Caroga avatar Caroga commented on May 18, 2024

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.

rossedman avatar rossedman commented on May 18, 2024

@Caroga Didn't mean to highjack your thread. Thought these issues were related. :)

from ansible-role-nginx.

Caroga avatar Caroga commented on May 18, 2024

Never a problem, all discussion helps!

from ansible-role-nginx.

stale avatar stale commented on May 18, 2024

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.

stale avatar stale commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.