nginx/ansible-role-nginx-config

nginx_config_main_template not deploying

Closed this issue · 1 comments

I am trying to execute the following playbook

---
- name: Basic setup
  hosts: gates
  collections:
    - nginxinc.nginx_core
  tasks:
    - name: Install NGINX
      include_role:
        name: nginx
    - name: Configure NGINX
      include_role:
        name: nginx_config
      vars:
        nginx_config_debug_output: true

        nginx_config_cleanup: true
        nginx_config_cleanup_paths:
          - directory:
              - /etc/nginx/conf.d
            recurse: false
        nginx_config_cleanup_files:
          - /etc/nginx/conf.d/default.conf
        nginx_config_main_template_enable: false
        nginx_config_main_template:
          template_file: nginx.conf.j2
          conf_file_name: nginx.conf
          conf_file_location: /etc/nginx/
          user: nginx
          worker_processes: auto
          worker_rlimit_nofile: 1024
          pid: /var/run/nginx.pid
          error_log:
            location: /var/log/nginx/error.log
            level: warn
          worker_connections: 1024
          http_enable: true
          access_log_format:
            - name: upstream_info
              format: |-
                '$remote_addr - $remote_user [$time_local] "$request" '
                '$status $body_bytes_sent "$http_referer" "$http_user_agent" '
                'rt=$request_time uct="$upstream_connect_time" uht="$upstream_header_time" urt="$upstream_response_time"'
          access_log_location:
            - name: upstream_info
              location: /var/log/nginx/access.log

but the nginx.conf is getting the default values:

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

I am running Ansible 4.1 and I have the 0.3.3 nginxinc.nginx_core collection

(cluster) joan@DESKTOP-OM8Q4NE:~/Abzu/cluster$ ansible --version
ansible [core 2.11.1]
  config file = /home/joan/Abzu/cluster/ansible.cfg
  configured module search path = ['/home/joan/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/joan/.local/share/virtualenvs/cluster-DtMsh1G5/lib/python3.8/site-packages/ansible
  ansible collection location = /home/joan/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/joan/.local/share/virtualenvs/cluster-DtMsh1G5/bin/ansible
  python version = 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0]
  jinja version = 3.0.0
  libyaml = True

You need to set nginx_config_main_template_enable: false to true :)