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
|
|
|
|
|
2017-10-05 03:32:32 +00:00
|
|
|
#+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]]
|
2018-01-09 21:38:12 +00:00
|
|
|
- [[#features][Features:]]
|
2017-05-22 14:16:12 +00:00
|
|
|
- [[#install][Install]]
|
|
|
|
- [[#configuration][Configuration]]
|
|
|
|
- [[#set-file-permission-on-save][Set file permission on save]]
|
2018-05-24 02:12:30 +00:00
|
|
|
- [[#indentation][Indentation]]
|
2017-10-15 13:50:49 +00:00
|
|
|
- [[#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
|
2018-01-09 21:38:12 +00:00
|
|
|
This layer adds support for CFEngine policies to Spacemacs.
|
2017-10-05 03:32:32 +00:00
|
|
|
|
2018-01-09 21:38:12 +00:00
|
|
|
** Features:
|
2020-06-07 17:32:15 +00:00
|
|
|
- Syntax highlighting (CFEngine DSL, Mustache)
|
2018-01-09 21:38:12 +00:00
|
|
|
- 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
|
|
|
|
2016-04-22 02:22:02 +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.
|
|
|
|
|
2016-04-22 02:22:02 +00:00
|
|
|
* 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
|
|
|
|
2016-04-22 02:22:02 +00:00
|
|
|
=File ./example.cf (owner 1000) is writable by others (security exception)=
|
2016-04-14 21:48:33 +00:00
|
|
|
|
2016-04-22 02:22:02 +00:00
|
|
|
#+BEGIN_SRC elisp
|
2017-10-05 03:32:32 +00:00
|
|
|
(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)."))))
|
2016-04-19 19:18:20 +00:00
|
|
|
|
2017-10-05 03:32:32 +00:00
|
|
|
(add-hook 'after-save-hook 'cfengine-permissions-policy-owner-only nil 'make-it-local)
|
2016-04-22 02:22:02 +00:00
|
|
|
#+END_SRC
|
2016-04-14 21:48:33 +00:00
|
|
|
|
2018-05-24 02:12:30 +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
|
|
|
|
2017-10-15 13:50:49 +00:00
|
|
|
* Execution of =cfengine3= SRC blocks
|
|
|
|
This layers add support for =cfengine3= source blocks in org files.
|
2017-10-05 03:32:32 +00:00
|
|
|
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
|
2017-10-05 03:32:32 +00:00
|
|
|
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
|
|
|
|
|
2018-12-05 03:03:03 +00:00
|
|
|
| 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 |
|