Hello,
I have a template with few variables to be populated, then I am shipping that template populated to a another server.
Here is my playbook :
- hosts: dev
become: yes
become_method: sudo
vars:
username: "{{ username }}"
ad_username: "{{ ad_username }}"
vhost_id: "{{ vhost_id }}"
tasks:
- name: Ansible Template
template:
src: /usr/local/cmd-sysadmin/automation/ansible/cmd/files/templates/apache_vhost_api_private_public.j2
dest: /usr/local/apache2.4/conf/vhosts/v2/{{ vhost_id }}_{{ username }}_apis.vhost.conf
- name: Add vhost to httpd.conf
shell: echo "Include conf/vhosts/v2/{{ vhost_id }}_{{ username }}_apis.vhost.conf" >> /usr/local/apache2.4/conf/httpd.conf
It works well if I call it from command line and I pass all variable via -e switch.
Something like : ansible-playbook playbooks/apache/create_new_vhost_from_template_dev.yml -K -e "username=xxxx ad_username=xxxx.xxx vhost_id=60"
As I have too many vhosts to be created, I got a file from where I would like to read content, iterate it, populate variables and push the file.
The file is like this :
I can modify the file to include the header, to be , delimited.. whatever.
Is there anyone that can explain how to do this?
It's hard for me to find something like this on the documentation.
Can anyone help?
Thanks