I have an http.conf where some values will be variables passed by the user
where should I put the variables and how the file should look can someone advice ?
I have an http.conf where some values will be variables passed by the user
where should I put the variables and how the file should look can someone advice ?
1). Send all your user input to ansible playbook command using —extra-vars. You can also pass as json and yaml file.
Example: # ansible-playbook site.yml —extra-vars “http_server_root=/var/www/html http_listen=8080 http_user=apache http_group=apache”
2). Create a template for your http.conf file with variable which you are passing via —extra-vars.
http.conf.j2
ServerRoot {{ http_server_root }}
Listen {{ http_listen }}
User {{ http_user }}
Group {{ http_group }}
3). Use template module to copy the config to target.
template:
src: httpd.conf.j2
dest: /etc/httpd/conf/httpd.conf
you can also use vars_prompt to create the variables
https://docs.ansible.com/ansible/latest/user_guide/playbooks_prompts.html