Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

Ansible - Templating

Back


Templating

server {
    listen 80;
    server_name ;

    location / {
        proxy_pass http://:;
    }
}
- hosts: webservers
  vars:
    server_name: mysite.com
    backend_host: 127.0.0.1
    backend_port: 5000

  tasks:
    - name: Deploy nginx configuration
      template:
        src: templates/nginx.conf.j2
        dest: /etc/nginx/nginx.conf
      notify: Restart nginx
# Variable substitution
Hello 

# Default values:


# Conditionals:

DEBUG = True


# Loops:


# Filters
hello   # Output: HELLO
 # Join list into a string

/etc/hosts    # hosts
c:\windows\hosts    # hosts, in windows
c:\windows\hosts    # ["c:","\windows\hosts"]
    # "c:"