This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+tools/cfengine/README.org

89 lines
2.6 KiB
Org Mode
Raw Normal View History

2016-04-14 21:48:33 +00:00
#+TITLE: CFEngine layer
2018-07-10 10:57:25 +00:00
2019-05-02 21:49:30 +00:00
#+TAGS: layer|tool
#+PROPERTY: header-args :eval never-export
2016-04-14 21:48:33 +00:00
[[file:./img/agent.png]]
2019-05-07 20:05:06 +00:00
* Table of Contents :TOC_5_gh:noexport:
2017-05-22 14:16:12 +00:00
- [[#description][Description]]
- [[#features][Features:]]
2017-05-22 14:16:12 +00:00
- [[#install][Install]]
- [[#configuration][Configuration]]
- [[#set-file-permission-on-save][Set file permission on save]]
- [[#indentation][Indentation]]
- [[#execution-of-cfengine3-src-blocks][Execution of =cfengine3= SRC blocks]]
2017-05-22 14:16:12 +00:00
- [[#key-bindings][Key bindings]]
2016-04-14 21:48:33 +00:00
* Description
This layer adds support for CFEngine policies to Spacemacs.
** Features:
- Syntax highlighting (CFEngine DSL, Mustache)
- On the fly syntax checking via =flycheck= integration.
- Auto completion via =company= integration.
- Execution of =cfengine3= =SRC= blocks in =org-mode= via =ob-cfengine3= package.
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
** Indentation
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:
2018-09-19 03:54:47 +00:00
#+BEGIN_SRC cfengine3
2016-04-14 21:48:33 +00:00
bundle agent main
{
vars:
"promiser"
string => "value",
comment => "Indented 2 spaces from promiser";
}
2018-09-19 03:54:47 +00:00
#+END_SRC
2016-04-14 21:48:33 +00:00
* Execution of =cfengine3= SRC blocks
This layers add support for =cfengine3= source blocks in org files.
With the insertion point inside the SRC block press ~,,~ or ~CTRL-c Ctrl-c~
2017-10-18 14:55:25 +00:00
#+BEGIN_SRC cfengine3
bundle agent main
{
reports:
"Hello World!";
}
#+END_SRC
See the ob-cfengine3 [[https://github.com/nickanderson/ob-cfengine3/blob/master/README.org][README]] for information on controlling inclusion of the
stdlib, definition of classes and controlling the =bundlesequence= using header
args.
To suppress the confirmation when executing a block set
=(setq org-confirm-babel-evaluate nil)= in =dotspacemacs/user-config()=.
2016-04-14 21:48:33 +00:00
* Key bindings
| Key binding | Description |
2016-04-14 21:48:33 +00:00
|-------------+-----------------------|
2017-04-25 15:42:58 +00:00
| ~SPC m j~ | Reformats JSON string |