spacemacs/layers/+tools/cfengine/README.org

60 lines
1.7 KiB
Org Mode
Raw Normal View History

2016-04-14 21:48:33 +00:00
#+TITLE: CFEngine layer
[[file:./img/agent.png]]
* Table of Contents :TOC_4_gh:noexport:
- [[#description][Description]]
- [[#install][Install]]
- [[#configuration][Configuration]]
- [[#set-file-permission-on-save][Set file permission on save]]
- [[#indendation][Indendation]]
- [[#key-bindings][Key bindings]]
2016-04-14 21:48:33 +00:00
* Description
This layer makes working with CFEngine policy easier:
- Syntax highlighting
- On the fly syntax checks (via =syntax-checking= layer)
- Auto completion (via =auto-completion= layer)
2016-04-14 21:48:33 +00:00
* Install
2016-04-14 21:48:33 +00:00
Add =cfengine= to the =dotspacemacs-configuration-layers= in your =~/.spacemacs=
to use this layer.
* Configuration
** Set file permission on save
Here is a function to set permissions to 600 on save, this can help avoid
errors like:
2016-04-14 21:48:33 +00:00
=File ./example.cf (owner 1000) is writable by others (security exception)=
2016-04-14 21:48:33 +00:00
#+BEGIN_SRC elisp
(defun cfengine-permissions-policy-owner-only ()
"If file starts with a shebang, make `buffer-file-name' executable"
(save-excursion
(set-file-modes buffer-file-name #o600)
(message (concat "Made " buffer-file-name " accessibly only by the owner (600)."))))
(add-hook 'after-save-hook 'cfengine-permissions-policy-owner-only nil 'make-it-local)
#+END_SRC
2016-04-14 21:48:33 +00:00
** Indendation
2016-04-14 21:48:33 +00:00
If you like attributes to be intended from the promiser set =Indentation amount
from anchor= to =2=. For example:
#+begin_src cfengine3
bundle agent main
{
vars:
"promiser"
string => "value",
comment => "Indented 2 spaces from promiser";
}
#+end_src
* Key bindings
| Key Binding | Description |
|-------------+-----------------------|
| ~<SPC> m j~ | Reformats JSON string |