Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx.ng with cli pillar data not generating config correctly #149

Closed
poppabear8883 opened this issue Feb 18, 2017 · 1 comment
Closed

Comments

@poppabear8883
Copy link

Hello, my use case is very specific to what I am building and must pass the pillar data in this manner. Other formula's and states work just fine, but this is the results I get from this formula when passing pillar data via the CLI

COMMAND:

salt 'homestead' state.sls nginx.ng pillar="{'nginx': {'ng': {'install_from_ppa': True, 'ppa_version': 'stable', 'service': {'enable': True}, 'from_source': False, 'servers': {'managed': {'default': {'config': None, 'enabled': False}, 'nxpanel.app': {'config': {'server': {'location /': {'try_files': ['$uri', '$uri/', '/index.php?$query_string']}, 'index': ['index.html', 'index.php', 'index.htm'], 'root': ['/usr/local/nxpanel/public'], 'server_name': 'nxpanel.app', 'listen': [80, 'default_server']}}, 'enabled': True, 'overwrite': True}}}, 'server': {'config': {'http': {'sendfile': 'on', 'types_hash_max_size': '2048', 'tcp_nodelay': 'on', 'gzip_disable': 'msie6', 'default_type': 'application/octet-stream', 'keepalive_timeout': '65', 'access_log': '/var/log/nginx/access.log', 'gzip': 'on', 'include': ['/etc/nginx/mime.types', '/etc/nginx/conf.d/*.conf', '/etc/nginx/sites-enabled/*']}, 'pid': '/run/nginx.pid', 'error_log': '/var/log/nginx/error.log', 'worker_processes': '20', 'user': 'www-data', 'events': {'worker_connections': '1024', 'multi_accept': 'on'}}}}}}" --out=json

RESULTS:

{
    "homestead": {
        "service_|-nginx_service_reload_|-nginx_|-running": {
            "comment": "The service nginx is already running", 
            "name": "nginx", 
            "start_time": "03:17:46.513832", 
            "result": true, 
            "duration": 17.034, 
            "__run_num__": 10, 
            "changes": {}, 
            "__id__": "nginx_service_reload"
        }, 
        "pkgrepo_|-nginx_ppa_repo_|-nginx_ppa_repo_|-managed": {
            "comment": "Configured package repo 'nginx_ppa_repo'", 
            "name": "nginx_ppa_repo", 
            "start_time": "03:17:45.424066", 
            "result": true, 
            "duration": 193.137, 
            "__run_num__": 0, 
            "changes": {}, 
            "__id__": "nginx_ppa_repo"
        }, 
        "file_|-server_state_1_|-/etc/nginx/sites-enabled/nxpanel.app_|-symlink": {
            "comment": "Symlink /etc/nginx/sites-enabled/nxpanel.app is present and owned by root:root", 
            "pchanges": {}, 
            "name": "/etc/nginx/sites-enabled/nxpanel.app", 
            "start_time": "03:17:46.511725", 
            "result": true, 
            "duration": 1.204, 
            "__run_num__": 9, 
            "changes": {}, 
            "__id__": "server_state_1"
        }, 
        "file_|-nginx_server_available_dir_|-/etc/nginx/sites-available_|-directory": {
            "comment": "Directory /etc/nginx/sites-available is in the correct state", 
            "pchanges": {}, 
            "name": "/etc/nginx/sites-available", 
            "start_time": "03:17:46.416386", 
            "result": true, 
            "duration": 0.457, 
            "__run_num__": 5, 
            "changes": {}, 
            "__id__": "nginx_server_available_dir"
        }, 
        "file_|-server_conf_1_|-/etc/nginx/sites-available/nxpanel.app_|-managed": {
            "comment": "File /etc/nginx/sites-available/nxpanel.app updated", 
            "pchanges": {}, 
            "name": "/etc/nginx/sites-available/nxpanel.app", 
            "start_time": "03:17:46.464360", 
            "result": true, 
            "duration": 46.971, 
            "__run_num__": 8, 
            "changes": {
                "diff": "New file", 
                "mode": "0644"
            }, 
            "__id__": "server_conf_1"
        }, 
        "file_|-server_conf_0_|-/etc/nginx/sites-available/default_|-managed": {
            "comment": "File /etc/nginx/sites-available/default is in the correct state", 
            "pchanges": {}, 
            "name": "/etc/nginx/sites-available/default", 
            "start_time": "03:17:46.416953", 
            "result": true, 
            "duration": 46.526, 
            "__run_num__": 6, 
            "changes": {}, 
            "__id__": "server_conf_0"
        }, 
        "service_|-listener_nginx_service_reload_|-nginx_|-mod_watch": {
            "comment": "Failed to reload the service", 
            "name": "nginx", 
            "start_time": "03:17:46.531187", 
            "result": false, 
            "duration": 47.918, 
            "__run_num__": 11, 
            "changes": {
                "nginx": false
            }, 
            "__id__": "listener_nginx_service_reload"
        }, 
        "service_|-nginx_service_|-nginx_|-running": {
            "comment": "Service nginx is already enabled, and is running", 
            "name": "nginx", 
            "start_time": "03:17:46.297097", 
            "__id__": "nginx_service", 
            "duration": 118.333, 
            "__run_num__": 3, 
            "changes": {
                "nginx": true
            }, 
            "result": true
        }, 
        "file_|-nginx_config_|-/etc/nginx/nginx.conf_|-managed": {
            "comment": "File /etc/nginx/nginx.conf is in the correct state", 
            "pchanges": {}, 
            "name": "/etc/nginx/nginx.conf", 
            "start_time": "03:17:46.243905", 
            "result": true, 
            "duration": 52.45, 
            "__run_num__": 2, 
            "changes": {}, 
            "__id__": "nginx_config"
        }, 
        "pkg_|-nginx_install_|-nginx_|-installed": {
            "comment": "Package nginx is already installed", 
            "name": "nginx", 
            "start_time": "03:17:45.617467", 
            "result": true, 
            "duration": 626.16, 
            "__run_num__": 1, 
            "changes": {}, 
            "__id__": "nginx_install"
        }, 
        "file_|-server_state_0_|-/etc/nginx/sites-enabled/default_|-absent": {
            "comment": "File /etc/nginx/sites-enabled/default is not present", 
            "pchanges": {}, 
            "name": "/etc/nginx/sites-enabled/default", 
            "start_time": "03:17:46.463891", 
            "result": true, 
            "duration": 0.375, 
            "__run_num__": 7, 
            "changes": {}, 
            "__id__": "server_state_0"
        }, 
        "file_|-nginx_server_enabled_dir_|-/etc/nginx/sites-enabled_|-directory": {
            "comment": "Directory /etc/nginx/sites-enabled is in the correct state", 
            "pchanges": {}, 
            "name": "/etc/nginx/sites-enabled", 
            "start_time": "03:17:46.415614", 
            "result": true, 
            "duration": 0.675, 
            "__run_num__": 4, 
            "changes": {}, 
            "__id__": "nginx_server_enabled_dir"
        }
    }
}

nxpanel.app CONFIG

# Nginx server configuration
#
# **** DO NOT EDIT THIS FILE ****
#
# This file is managed by Salt.

 server;

and a nicer formatted example of the above dictionary that was passed

{
    'nginx': {
        'ng': {
            'install_from_ppa': True,
            'ppa_version': 'stable',
            'service': {
                'enable': True
            },
            'from_source': False,
            'servers': {
                'managed': {
                    'default': {
                        'config': None,
                        'enabled': False
                    },
                    'nxpanel.app': {
                        'config': {
                            'server': {
                                'location /': {
                                    'try_files': ['$uri', '$uri/', '/index.php?$query_string']
                                },
                                'index': ['index.html', 'index.php', 'index.htm'],
                                'root': ['/usr/local/nxpanel/public'],
                                'server_name': 'nxpanel.app',
                                'listen': [80, 'default_server']
                            }
                        },
                        'enabled': True,
                        'overwrite': True
                    }
                }
            },
            'server': {
                'config': {
                    'http': {
                        'sendfile': 'on',
                        'types_hash_max_size': '2048',
                        'tcp_nodelay': 'on',
                        'gzip_disable': 'msie6',
                        'default_type': 'application/octet-stream',
                        'keepalive_timeout': '65',
                        'access_log': '/var/log/nginx/access.log',
                        'gzip': 'on',
                        'include': ['/etc/nginx/mime.types', '/etc/nginx/conf.d/*.conf', '/etc/nginx/sites-enabled/*']
                    },
                    'pid': '/run/nginx.pid',
                    'error_log': '/var/log/nginx/error.log',
                    'worker_processes': '20',
                    'user': 'www-data',
                    'events': {
                        'worker_connections': '1024',
                        'multi_accept': 'on'
                    }
                }
            }
        }
    }
}
@poppabear8883
Copy link
Author

Appears its a formatting issue on my part. servers should be a list of dictionaries. thanks to help from the IRC channel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant