Skip to content

Instantly share code, notes, and snippets.

@wtcross
wtcross / example.yml
Created November 19, 2019 21:10
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
@wtcross
wtcross / netbox-ansible.py
Created April 17, 2017 20:02 — forked from linuxsimba/netbox-ansible.py
Ansible Netbox Integration Example
#!/usr/bin/python
""" Ansible Inventory Generated From Netbox
Author: Stanley Karunditu <stanley@linuxsimba.com>
License: MIT
Requirements:
* use netbox device roles that result in hyphenated role names. E.g
@wtcross
wtcross / provision-instance.yml
Created June 14, 2016 15:01
Example of an Ansible playbook that interacts with OpenStack. It is runnable via Ansible and Ansible Tower.
```yaml
- name: Provision a compute instance
hosts: localhost
gather_facts: no
become: no
vars:
os_config_file: "{{ lookup('env', 'OS_CLIENT_CONFIG_FILE') }}"
os_auth:
project_name: "{{ lookup('env', 'OS_PROJECT') }}"
auth_url: "{{ lookup('env', 'OS_AUTH_URL') }}"
@wtcross
wtcross / markdown-comments.md
Last active August 29, 2015 14:22
Comments in Markdown

Comments in Markdown

Sometimes it is useful to put comments in a markdown file. A good example is when creating a "template" markdown file that is then completed by somebody.

Since this is demonstrating comments in markdown, you will need to view the raw file to see the example.

@wtcross
wtcross / gist:71221c6bf1d65839de12
Last active August 29, 2015 14:19
become_user example

In a play All tasks are ran as the become_user user.

- name: Super awesome play.
  become_user: tyler

  tasks:
    - name: Some task
      copy: src=/foo dest=/bar
@wtcross
wtcross / user-yaml-as-yaml-with-ansible.md
Last active March 12, 2016 00:24
Use YAML as YAML with Ansible

As a software engineer I require a consistent style in any configuration or code. Static analysis and style checking are very important for project health. These procedures have a place in any project.

With Ansible, parameters can be written as fully expanded YAML dictionaries or as condensed key=value pairs. It is left up to the user to decide between the styles. Working on playbooks, roles, or tasks that use both styles can be tedious compared to just using expanded YAML dictionaries.

Something that I have recently decided on is to use YAML as YAML with Ansible. I use fully expanded YAML dictionaries everywhere now. My recommendation is that you try it, too.