Skip to content

Instantly share code, notes, and snippets.

@wtcross
Created November 19, 2019 21:10
Show Gist options
  • Save wtcross/7421952cc2f8ffe2fa47734affc8212f to your computer and use it in GitHub Desktop.
Save wtcross/7421952cc2f8ffe2fa47734affc8212f to your computer and use it in GitHub Desktop.
Example Ansible playbook that uses vars
---
- name: install and start apache
hosts: web
become: yes
vars:
http_port: 80
tasks:
- name: httpd package is present
yum:
name: httpd
state: latest
- name: latest index.html file is present
template:
src: files/index.html
dest: /var/www/html/
- name: firewall allows http traffic
firewalld:
port: "{{ http_port }}/tcp"
permanent: yes
state: enabled
- name: httpd is started
service:
name: httpd
state: started
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment