Skip to content

Instantly share code, notes, and snippets.

@dsoares
Last active November 24, 2018 11:26
Show Gist options
  • Save dsoares/a95b6701a6ff9cfd4a4b to your computer and use it in GitHub Desktop.
Save dsoares/a95b6701a6ff9cfd4a4b to your computer and use it in GitHub Desktop.
Atom.io snippets for ansible
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
# '.source.coffee':
# 'Console log':
# 'prefix': 'log'
# 'body': 'console.log $1'
#
# Each scope (e.g. '.source.coffee' above) can only be declared once.
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it in the
# Atom Flight Manual:
# https://atom.io/docs/latest/using-atom-basic-customization#cson
'.source.js':
'console.log':
'prefix': 'log'
'body': 'console.log(${1:"crash"});$2'
#
# Ansible snippets
#
'.source.ansible':
'Ansible init main.yml':
'prefix': '---'
'body': """
---
# file: ${1:tasks} main.yml
- name: ${2:NAME}
"""
'Ansible copy':
'prefix': 'copy:'
'body': """
src="${1:SRC}" dest="${2:DEST}"
"""
'Ansible file':
'prefix': 'file:'
'body': """
file: path="$1"
state=${2:directory} mode=$3 owner=$4 group=$5
"""
'Ansible getUrl':
'prefix': 'getUrl:'
'body': """
get_url:
url: $1
dest: $2
owner: $3
group: $4
mode: $5
"""
'Ansible lineinfile':
'prefix': 'lineinfile:'
'body': """
lineinfile:
dest: $1
line: $2
regexp: $3
insert${4:after}: ${5:EOF}
state: present
backup: yes
create: yes
mode: 0644
"""
'Ansible service':
'prefix': 'service:'
'body': """
service: name=$1 enabled=$2 state=$3
"""
'Ansible template':
'prefix': 'template:'
'body': """
template:
src: $1
dest: $2
owner: $3
group: $4
mode: $5
backup: $6
validate: $7
"""
'Ansible yum':
'prefix': 'yum:'
'body': """
yum: name=$1 state=$2
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment