pulibrary / princeton_ansible

Ansible Roles and Playbooks for Princeton University Library
10 stars 4 forks source link

nginxplus: only the configs in our config directory should exist on the server #2750

Closed hackartisan closed 6 days ago

hackartisan commented 2 years ago

e.g. if an old config is removed from ansible it should also be removed from the remote server.

Current behavior is that the old config is still there after the playbook has been run.

acozine commented 2 years ago

The current role has a tasks file with a single task that "cleans up" the config. It removes the entire config directory. The role includes that file only when the variable nginx_cleanup_config is set to true - that var is set to false in the role defaults.

Do we want that task to run every time we upload new configs? So that each time the playbook runs (unless it runs with -t SSL) , it would delete the config directory and upload all configs from scratch? If so, we can put it in the upload_config.yml tasks file, before the upload task, and tag it with tags: update_conf.

If we only want that task to run occasionally, we can update the README and playbooks to document the existing behavior: "To remove all existing config files before uploading, pass -e nginx_cleanup_config=true when you run the playbook."

acozine commented 2 years ago

Per @tpendragon we can use the synchronize module with delete.

acozine commented 2 years ago

Add a test for this new behavior. Probably needs a pre-task in molecule/default/converge.yml that adds an extraneous file, then a test in molecule/default/verify.yml that checks to be sure the file disappears when the playbook runs.

acozine commented 1 year ago

Test for this as part of #3439

acozine commented 8 months ago

Related to #4654 - I think that PR should fix/close this ticket, except we are not testing for this behavior yet.