docs: Fix headers formating
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#mgmt
|
# mgmt
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Mgmt
|
Mgmt
|
||||||
@@ -19,13 +19,13 @@ You should have received a copy of the GNU Affero General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
##mgmt by [James](https://ttboj.wordpress.com/)
|
## mgmt by [James](https://ttboj.wordpress.com/)
|
||||||
####Available from:
|
#### Available from:
|
||||||
####[https://github.com/purpleidea/mgmt/](https://github.com/purpleidea/mgmt/)
|
#### [https://github.com/purpleidea/mgmt/](https://github.com/purpleidea/mgmt/)
|
||||||
|
|
||||||
####This documentation is available in: [Markdown](https://github.com/purpleidea/mgmt/blob/master/docs/documentation.md) or [PDF](https://pdfdoc-purpleidea.rhcloud.com/pdf/https://github.com/purpleidea/mgmt/blob/master/docs/documentation.md) format.
|
#### This documentation is available in: [Markdown](https://github.com/purpleidea/mgmt/blob/master/docs/documentation.md) or [PDF](https://pdfdoc-purpleidea.rhcloud.com/pdf/https://github.com/purpleidea/mgmt/blob/master/docs/documentation.md) format.
|
||||||
|
|
||||||
####Table of Contents
|
#### Table of Contents
|
||||||
|
|
||||||
1. [Overview](#overview)
|
1. [Overview](#overview)
|
||||||
2. [Project description - What the project does](#project-description)
|
2. [Project description - What the project does](#project-description)
|
||||||
@@ -46,12 +46,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
9. [Development - Background on module development and reporting bugs](#development)
|
9. [Development - Background on module development and reporting bugs](#development)
|
||||||
10. [Authors - Authors and contact information](#authors)
|
10. [Authors - Authors and contact information](#authors)
|
||||||
|
|
||||||
##Overview
|
## Overview
|
||||||
|
|
||||||
The `mgmt` tool is a next generation config management prototype. It's not yet
|
The `mgmt` tool is a next generation config management prototype. It's not yet
|
||||||
ready for production, but we hope to get there soon. Get involved today!
|
ready for production, but we hope to get there soon. Get involved today!
|
||||||
|
|
||||||
##Project Description
|
## Project Description
|
||||||
|
|
||||||
The mgmt tool is a distributed, event driven, config management tool, that
|
The mgmt tool is a distributed, event driven, config management tool, that
|
||||||
supports parallel execution, and librarification to be used as the management
|
supports parallel execution, and librarification to be used as the management
|
||||||
@@ -69,7 +69,7 @@ For more information, you may like to read some blog posts from the author:
|
|||||||
There is also an [introductory video](http://meetings-archive.debian.net/pub/debian-meetings/2016/debconf16/Next_Generation_Config_Mgmt.webm) available.
|
There is also an [introductory video](http://meetings-archive.debian.net/pub/debian-meetings/2016/debconf16/Next_Generation_Config_Mgmt.webm) available.
|
||||||
Older videos and other material [is available](https://github.com/purpleidea/mgmt/#on-the-web).
|
Older videos and other material [is available](https://github.com/purpleidea/mgmt/#on-the-web).
|
||||||
|
|
||||||
##Setup
|
## Setup
|
||||||
|
|
||||||
During this prototype phase, the tool can be run out of the source directory.
|
During this prototype phase, the tool can be run out of the source directory.
|
||||||
You'll probably want to use ```./run.sh run --yaml examples/graph1.yaml``` to
|
You'll probably want to use ```./run.sh run --yaml examples/graph1.yaml``` to
|
||||||
@@ -77,12 +77,12 @@ get started. Beware that this _can_ cause data loss. Understand what you're
|
|||||||
doing first, or perform these actions in a virtual environment such as the one
|
doing first, or perform these actions in a virtual environment such as the one
|
||||||
provided by [Oh-My-Vagrant](https://github.com/purpleidea/oh-my-vagrant).
|
provided by [Oh-My-Vagrant](https://github.com/purpleidea/oh-my-vagrant).
|
||||||
|
|
||||||
##Features
|
## Features
|
||||||
|
|
||||||
This section details the numerous features of mgmt and some caveats you might
|
This section details the numerous features of mgmt and some caveats you might
|
||||||
need to be aware of.
|
need to be aware of.
|
||||||
|
|
||||||
###Autoedges
|
### Autoedges
|
||||||
|
|
||||||
Automatic edges, or AutoEdges, is the mechanism in mgmt by which it will
|
Automatic edges, or AutoEdges, is the mechanism in mgmt by which it will
|
||||||
automatically create dependencies for you between resources. For example,
|
automatically create dependencies for you between resources. For example,
|
||||||
@@ -91,7 +91,7 @@ automatically ensure that any file resource you declare that matches a
|
|||||||
file installed by your package resource will only be processed after the
|
file installed by your package resource will only be processed after the
|
||||||
package is installed.
|
package is installed.
|
||||||
|
|
||||||
####Controlling autoedges
|
#### Controlling autoedges
|
||||||
|
|
||||||
Though autoedges is likely to be very helpful and avoid you having to declare
|
Though autoedges is likely to be very helpful and avoid you having to declare
|
||||||
all dependencies explicitly, there are cases where this behaviour is
|
all dependencies explicitly, there are cases where this behaviour is
|
||||||
@@ -108,12 +108,12 @@ installation of the `mysql-server` package.
|
|||||||
You can disable autoedges for a resource by setting the `autoedge` key on
|
You can disable autoedges for a resource by setting the `autoedge` key on
|
||||||
the meta attributes of that resource to `false`.
|
the meta attributes of that resource to `false`.
|
||||||
|
|
||||||
####Blog post
|
#### Blog post
|
||||||
|
|
||||||
You can read the introductory blog post about this topic here:
|
You can read the introductory blog post about this topic here:
|
||||||
[https://ttboj.wordpress.com/2016/03/14/automatic-edges-in-mgmt/](https://ttboj.wordpress.com/2016/03/14/automatic-edges-in-mgmt/)
|
[https://ttboj.wordpress.com/2016/03/14/automatic-edges-in-mgmt/](https://ttboj.wordpress.com/2016/03/14/automatic-edges-in-mgmt/)
|
||||||
|
|
||||||
###Autogrouping
|
### Autogrouping
|
||||||
|
|
||||||
Automatic grouping or AutoGroup is the mechanism in mgmt by which it will
|
Automatic grouping or AutoGroup is the mechanism in mgmt by which it will
|
||||||
automatically group multiple resource vertices into a single one. This is
|
automatically group multiple resource vertices into a single one. This is
|
||||||
@@ -127,12 +127,12 @@ used for other use cases too.
|
|||||||
You can disable autogrouping for a resource by setting the `autogroup` key on
|
You can disable autogrouping for a resource by setting the `autogroup` key on
|
||||||
the meta attributes of that resource to `false`.
|
the meta attributes of that resource to `false`.
|
||||||
|
|
||||||
####Blog post
|
#### Blog post
|
||||||
|
|
||||||
You can read the introductory blog post about this topic here:
|
You can read the introductory blog post about this topic here:
|
||||||
[https://ttboj.wordpress.com/2016/03/30/automatic-grouping-in-mgmt/](https://ttboj.wordpress.com/2016/03/30/automatic-grouping-in-mgmt/)
|
[https://ttboj.wordpress.com/2016/03/30/automatic-grouping-in-mgmt/](https://ttboj.wordpress.com/2016/03/30/automatic-grouping-in-mgmt/)
|
||||||
|
|
||||||
###Automatic clustering
|
### Automatic clustering
|
||||||
|
|
||||||
Automatic clustering is a feature by which mgmt automatically builds, scales,
|
Automatic clustering is a feature by which mgmt automatically builds, scales,
|
||||||
and manages the embedded etcd cluster which is compiled into mgmt itself. It is
|
and manages the embedded etcd cluster which is compiled into mgmt itself. It is
|
||||||
@@ -143,12 +143,12 @@ If you prefer to avoid this feature. you can always opt to use an existing etcd
|
|||||||
cluster that is managed separately from mgmt by pointing your mgmt agents at it
|
cluster that is managed separately from mgmt by pointing your mgmt agents at it
|
||||||
with the `--seeds` variable.
|
with the `--seeds` variable.
|
||||||
|
|
||||||
####Blog post
|
#### Blog post
|
||||||
|
|
||||||
You can read the introductory blog post about this topic here:
|
You can read the introductory blog post about this topic here:
|
||||||
[https://ttboj.wordpress.com/2016/06/20/automatic-clustering-in-mgmt/](https://ttboj.wordpress.com/2016/06/20/automatic-clustering-in-mgmt/)
|
[https://ttboj.wordpress.com/2016/06/20/automatic-clustering-in-mgmt/](https://ttboj.wordpress.com/2016/06/20/automatic-clustering-in-mgmt/)
|
||||||
|
|
||||||
###Remote ("agent-less") mode
|
### Remote ("agent-less") mode
|
||||||
|
|
||||||
Remote mode is a special mode that lets you kick off mgmt runs on one or more
|
Remote mode is a special mode that lets you kick off mgmt runs on one or more
|
||||||
remote machines which are only accessible via SSH. In this mode the initiating
|
remote machines which are only accessible via SSH. In this mode the initiating
|
||||||
@@ -170,12 +170,12 @@ entire set of running mgmt agents will need to all simultaneously converge for
|
|||||||
the group to exit. This is particularly useful for bootstrapping new clusters
|
the group to exit. This is particularly useful for bootstrapping new clusters
|
||||||
which need to exchange information that is only available at run time.
|
which need to exchange information that is only available at run time.
|
||||||
|
|
||||||
####Blog post
|
#### Blog post
|
||||||
|
|
||||||
You can read the introductory blog post about this topic here:
|
You can read the introductory blog post about this topic here:
|
||||||
[https://ttboj.wordpress.com/2016/10/07/remote-execution-in-mgmt/](https://ttboj.wordpress.com/2016/10/07/remote-execution-in-mgmt/)
|
[https://ttboj.wordpress.com/2016/10/07/remote-execution-in-mgmt/](https://ttboj.wordpress.com/2016/10/07/remote-execution-in-mgmt/)
|
||||||
|
|
||||||
###Puppet support
|
### Puppet support
|
||||||
|
|
||||||
You can supply a Puppet manifest instead of creating the (YAML) graph manually.
|
You can supply a Puppet manifest instead of creating the (YAML) graph manually.
|
||||||
Puppet must be installed and in `mgmt`'s search path. You also need the
|
Puppet must be installed and in `mgmt`'s search path. You also need the
|
||||||
@@ -197,12 +197,12 @@ Invoke `mgmt` with the `--puppet` switch, which supports 3 variants:
|
|||||||
|
|
||||||
For more details and caveats see [Puppet.md](Puppet.md).
|
For more details and caveats see [Puppet.md](Puppet.md).
|
||||||
|
|
||||||
####Blog post
|
#### Blog post
|
||||||
|
|
||||||
An introductory post on the Puppet support is on
|
An introductory post on the Puppet support is on
|
||||||
[Felix's blog](http://ffrank.github.io/features/2016/06/19/puppet-powered-mgmt/).
|
[Felix's blog](http://ffrank.github.io/features/2016/06/19/puppet-powered-mgmt/).
|
||||||
|
|
||||||
##Resources
|
## Resources
|
||||||
|
|
||||||
This section lists all the built-in resources and their properties. The
|
This section lists all the built-in resources and their properties. The
|
||||||
resource primitives in `mgmt` are typically more powerful than resources in
|
resource primitives in `mgmt` are typically more powerful than resources in
|
||||||
@@ -230,45 +230,45 @@ parameter with the [Noop](#Noop) resource.
|
|||||||
* [Timer](#Timer): Manage system systemd services.
|
* [Timer](#Timer): Manage system systemd services.
|
||||||
* [Virt](#Virt): Manage virtual machines with libvirt.
|
* [Virt](#Virt): Manage virtual machines with libvirt.
|
||||||
|
|
||||||
###Exec
|
### Exec
|
||||||
|
|
||||||
The exec resource can execute commands on your system.
|
The exec resource can execute commands on your system.
|
||||||
|
|
||||||
###File
|
### File
|
||||||
|
|
||||||
The file resource manages files and directories. In `mgmt`, directories are
|
The file resource manages files and directories. In `mgmt`, directories are
|
||||||
identified by a trailing slash in their path name. File have no such slash.
|
identified by a trailing slash in their path name. File have no such slash.
|
||||||
|
|
||||||
####Path
|
#### Path
|
||||||
|
|
||||||
The path property specifies the file or directory that we are managing.
|
The path property specifies the file or directory that we are managing.
|
||||||
|
|
||||||
####Content
|
#### Content
|
||||||
|
|
||||||
The content property is a string that specifies the desired file contents.
|
The content property is a string that specifies the desired file contents.
|
||||||
|
|
||||||
####Source
|
#### Source
|
||||||
|
|
||||||
The source property points to a source file or directory path that we wish to
|
The source property points to a source file or directory path that we wish to
|
||||||
copy over and use as the desired contents for our resource.
|
copy over and use as the desired contents for our resource.
|
||||||
|
|
||||||
####State
|
#### State
|
||||||
|
|
||||||
The state property describes the action we'd like to apply for the resource. The
|
The state property describes the action we'd like to apply for the resource. The
|
||||||
possible values are: `exists` and `absent`.
|
possible values are: `exists` and `absent`.
|
||||||
|
|
||||||
####Recurse
|
#### Recurse
|
||||||
|
|
||||||
The recurse property limits whether file resource operations should recurse into
|
The recurse property limits whether file resource operations should recurse into
|
||||||
and monitor directory contents with a depth greater than one.
|
and monitor directory contents with a depth greater than one.
|
||||||
|
|
||||||
####Force
|
#### Force
|
||||||
|
|
||||||
The force property is required if we want the file resource to be able to change
|
The force property is required if we want the file resource to be able to change
|
||||||
a file into a directory or vice-versa. If such a change is needed, but the force
|
a file into a directory or vice-versa. If such a change is needed, but the force
|
||||||
property is not set to `true`, then this file resource will error.
|
property is not set to `true`, then this file resource will error.
|
||||||
|
|
||||||
###Hostname
|
### Hostname
|
||||||
|
|
||||||
The hostname resource manages static, transient/dynamic and pretty hostnames
|
The hostname resource manages static, transient/dynamic and pretty hostnames
|
||||||
on the system and watches them for changes.
|
on the system and watches them for changes.
|
||||||
@@ -292,55 +292,55 @@ The pretty hostname is a free-form UTF8 host name for presentation to the user.
|
|||||||
Hostname is the fallback value for all 3 fields above, if only `hostname` is
|
Hostname is the fallback value for all 3 fields above, if only `hostname` is
|
||||||
specified, it will set all 3 fields to this value.
|
specified, it will set all 3 fields to this value.
|
||||||
|
|
||||||
###Msg
|
### Msg
|
||||||
|
|
||||||
The msg resource sends messages to the main log, or an external service such
|
The msg resource sends messages to the main log, or an external service such
|
||||||
as systemd's journal.
|
as systemd's journal.
|
||||||
|
|
||||||
###Noop
|
### Noop
|
||||||
|
|
||||||
The noop resource does absolutely nothing. It does have some utility in testing
|
The noop resource does absolutely nothing. It does have some utility in testing
|
||||||
`mgmt` and also as a placeholder in the resource graph.
|
`mgmt` and also as a placeholder in the resource graph.
|
||||||
|
|
||||||
###Nspawn
|
### Nspawn
|
||||||
|
|
||||||
The nspawn resource is used to manage systemd-machined style containers.
|
The nspawn resource is used to manage systemd-machined style containers.
|
||||||
|
|
||||||
###Password
|
### Password
|
||||||
|
|
||||||
The password resource can generate a random string to be used as a password. It
|
The password resource can generate a random string to be used as a password. It
|
||||||
will re-generate the password if it receives a refresh notification.
|
will re-generate the password if it receives a refresh notification.
|
||||||
|
|
||||||
###Pkg
|
### Pkg
|
||||||
|
|
||||||
The pkg resource is used to manage system packages. This resource works on many
|
The pkg resource is used to manage system packages. This resource works on many
|
||||||
different distributions because it uses the underlying packagekit facility which
|
different distributions because it uses the underlying packagekit facility which
|
||||||
supports different backends for different environments. This ensures that we
|
supports different backends for different environments. This ensures that we
|
||||||
have great Debian (deb/dpkg) and Fedora (rpm/dnf) support simultaneously.
|
have great Debian (deb/dpkg) and Fedora (rpm/dnf) support simultaneously.
|
||||||
|
|
||||||
###Svc
|
### Svc
|
||||||
|
|
||||||
The service resource is still very WIP. Please help us my improving it!
|
The service resource is still very WIP. Please help us my improving it!
|
||||||
|
|
||||||
###Timer
|
### Timer
|
||||||
|
|
||||||
This resource needs better documentation. Please help us my improving it!
|
This resource needs better documentation. Please help us my improving it!
|
||||||
|
|
||||||
###Virt
|
### Virt
|
||||||
|
|
||||||
The virt resource can manage virtual machines via libvirt.
|
The virt resource can manage virtual machines via libvirt.
|
||||||
|
|
||||||
##Usage and frequently asked questions
|
## Usage and frequently asked questions
|
||||||
(Send your questions as a patch to this FAQ! I'll review it, merge it, and
|
(Send your questions as a patch to this FAQ! I'll review it, merge it, and
|
||||||
respond by commit with the answer.)
|
respond by commit with the answer.)
|
||||||
|
|
||||||
###Why did you start this project?
|
### Why did you start this project?
|
||||||
|
|
||||||
I wanted a next generation config management solution that didn't have all of
|
I wanted a next generation config management solution that didn't have all of
|
||||||
the design flaws or limitations that the current generation of tools do, and no
|
the design flaws or limitations that the current generation of tools do, and no
|
||||||
tool existed!
|
tool existed!
|
||||||
|
|
||||||
###Why did you use etcd? What about consul?
|
### Why did you use etcd? What about consul?
|
||||||
|
|
||||||
Etcd and consul are both written in golang, which made them the top two
|
Etcd and consul are both written in golang, which made them the top two
|
||||||
contenders for my prototype. Ultimately a choice had to be made, and etcd was
|
contenders for my prototype. Ultimately a choice had to be made, and etcd was
|
||||||
@@ -348,7 +348,7 @@ chosen, but it was also somewhat arbitrary. If there is available interest,
|
|||||||
good reasoning, *and* patches, then we would consider either switching or
|
good reasoning, *and* patches, then we would consider either switching or
|
||||||
supporting both, but this is not a high priority at this time.
|
supporting both, but this is not a high priority at this time.
|
||||||
|
|
||||||
###Can I use an existing etcd cluster instead of the automatic embedded servers?
|
### Can I use an existing etcd cluster instead of the automatic embedded servers?
|
||||||
|
|
||||||
Yes, it's possible to use an existing etcd cluster instead of the automatic,
|
Yes, it's possible to use an existing etcd cluster instead of the automatic,
|
||||||
elastic embedded etcd servers. To do so, simply point to the cluster with the
|
elastic embedded etcd servers. To do so, simply point to the cluster with the
|
||||||
@@ -359,7 +359,7 @@ The downside to this approach is that you won't benefit from the automatic
|
|||||||
elastic nature of the embedded etcd servers, and that you're responsible if you
|
elastic nature of the embedded etcd servers, and that you're responsible if you
|
||||||
accidentally break your etcd cluster, or if you use an unsupported version.
|
accidentally break your etcd cluster, or if you use an unsupported version.
|
||||||
|
|
||||||
###What does the error message about an inconsistent dataDir mean?
|
### What does the error message about an inconsistent dataDir mean?
|
||||||
|
|
||||||
If you get an error message similar to:
|
If you get an error message similar to:
|
||||||
|
|
||||||
@@ -377,7 +377,7 @@ starting up, and as a result, a default endpoint never gets added. The solution
|
|||||||
is to either reconcile the mistake, and if there is no important data saved, you
|
is to either reconcile the mistake, and if there is no important data saved, you
|
||||||
can remove the etcd dataDir. This is typically `/var/lib/mgmt/etcd/member/`.
|
can remove the etcd dataDir. This is typically `/var/lib/mgmt/etcd/member/`.
|
||||||
|
|
||||||
###Why do resources have both a `Compare` method and an `IFF` (on the UID) method?
|
### Why do resources have both a `Compare` method and an `IFF` (on the UID) method?
|
||||||
|
|
||||||
The `Compare()` methods are for determining if two resources are effectively the
|
The `Compare()` methods are for determining if two resources are effectively the
|
||||||
same, which is used to make graph change delta's efficient. This is when we want
|
same, which is used to make graph change delta's efficient. This is when we want
|
||||||
@@ -393,14 +393,14 @@ equality. In the future it might be helpful or sane to merge the two similar
|
|||||||
comparison functions although for now they are separate because they are
|
comparison functions although for now they are separate because they are
|
||||||
actually answer different questions.
|
actually answer different questions.
|
||||||
|
|
||||||
###Did you know that there is a band named `MGMT`?
|
### Did you know that there is a band named `MGMT`?
|
||||||
|
|
||||||
I didn't realize this when naming the project, and it is accidental. After much
|
I didn't realize this when naming the project, and it is accidental. After much
|
||||||
anguishing, I chose the name because it was short and I thought it was
|
anguishing, I chose the name because it was short and I thought it was
|
||||||
appropriately descriptive. If you need a less ambiguous search term or phrase,
|
appropriately descriptive. If you need a less ambiguous search term or phrase,
|
||||||
you can try using `mgmtconfig` or `mgmt config`.
|
you can try using `mgmtconfig` or `mgmt config`.
|
||||||
|
|
||||||
###You didn't answer my question, or I have a question!
|
### You didn't answer my question, or I have a question!
|
||||||
|
|
||||||
It's best to ask on [IRC](https://webchat.freenode.net/?channels=#mgmtconfig)
|
It's best to ask on [IRC](https://webchat.freenode.net/?channels=#mgmtconfig)
|
||||||
to see if someone can help you. Once we get a big enough community going, we'll
|
to see if someone can help you. Once we get a big enough community going, we'll
|
||||||
@@ -410,40 +410,40 @@ and I'll do my best to help. If you have a good question, please add it as a
|
|||||||
patch to this documentation. I'll merge your question, and add a patch with the
|
patch to this documentation. I'll merge your question, and add a patch with the
|
||||||
answer!
|
answer!
|
||||||
|
|
||||||
##Reference
|
## Reference
|
||||||
Please note that there are a number of undocumented options. For more
|
Please note that there are a number of undocumented options. For more
|
||||||
information on these options, please view the source at:
|
information on these options, please view the source at:
|
||||||
[https://github.com/purpleidea/mgmt/](https://github.com/purpleidea/mgmt/).
|
[https://github.com/purpleidea/mgmt/](https://github.com/purpleidea/mgmt/).
|
||||||
If you feel that a well used option needs documenting here, please patch it!
|
If you feel that a well used option needs documenting here, please patch it!
|
||||||
|
|
||||||
###Overview of reference
|
### Overview of reference
|
||||||
* [Meta parameters](#meta-parameters): List of available resource meta parameters.
|
* [Meta parameters](#meta-parameters): List of available resource meta parameters.
|
||||||
* [Graph definition file](#graph-definition-file): Main graph definition file.
|
* [Graph definition file](#graph-definition-file): Main graph definition file.
|
||||||
* [Command line](#command-line): Command line parameters.
|
* [Command line](#command-line): Command line parameters.
|
||||||
|
|
||||||
###Meta parameters
|
### Meta parameters
|
||||||
These meta parameters are special parameters (or properties) which can apply to
|
These meta parameters are special parameters (or properties) which can apply to
|
||||||
any resource. The usefulness of doing so will depend on the particular meta
|
any resource. The usefulness of doing so will depend on the particular meta
|
||||||
parameter and resource combination.
|
parameter and resource combination.
|
||||||
|
|
||||||
####AutoEdge
|
#### AutoEdge
|
||||||
Boolean. Should we generate auto edges for this resource?
|
Boolean. Should we generate auto edges for this resource?
|
||||||
|
|
||||||
####AutoGroup
|
#### AutoGroup
|
||||||
Boolean. Should we attempt to automatically group this resource with others?
|
Boolean. Should we attempt to automatically group this resource with others?
|
||||||
|
|
||||||
####Noop
|
#### Noop
|
||||||
Boolean. Should the Apply portion of the CheckApply method of the resource
|
Boolean. Should the Apply portion of the CheckApply method of the resource
|
||||||
make any changes? Noop is a concatenation of no-operation.
|
make any changes? Noop is a concatenation of no-operation.
|
||||||
|
|
||||||
####Retry
|
#### Retry
|
||||||
Integer. The number of times to retry running the resource on error. Use -1 for
|
Integer. The number of times to retry running the resource on error. Use -1 for
|
||||||
infinite. This currently applies for both the Watch operation (which can fail)
|
infinite. This currently applies for both the Watch operation (which can fail)
|
||||||
and for the CheckApply operation. While they could have separate values, I've
|
and for the CheckApply operation. While they could have separate values, I've
|
||||||
decided to use the same ones for both until there's a proper reason to want to
|
decided to use the same ones for both until there's a proper reason to want to
|
||||||
do something differently for the Watch errors.
|
do something differently for the Watch errors.
|
||||||
|
|
||||||
####Delay
|
#### Delay
|
||||||
Integer. Number of milliseconds to wait between retries. The same value is
|
Integer. Number of milliseconds to wait between retries. The same value is
|
||||||
shared between the Watch and CheckApply retries. This currently applies for both
|
shared between the Watch and CheckApply retries. This currently applies for both
|
||||||
the Watch operation (which can fail) and for the CheckApply operation. While
|
the Watch operation (which can fail) and for the CheckApply operation. While
|
||||||
@@ -451,7 +451,7 @@ they could have separate values, I've decided to use the same ones for both
|
|||||||
until there's a proper reason to want to do something differently for the Watch
|
until there's a proper reason to want to do something differently for the Watch
|
||||||
errors.
|
errors.
|
||||||
|
|
||||||
####Poll
|
#### Poll
|
||||||
Integer. Number of seconds to wait between `CheckApply` checks. If this is
|
Integer. Number of seconds to wait between `CheckApply` checks. If this is
|
||||||
greater than zero, then the standard event based `Watch` mechanism for this
|
greater than zero, then the standard event based `Watch` mechanism for this
|
||||||
resource is replaced with a simple polling mechanism. In general, this is not
|
resource is replaced with a simple polling mechanism. In general, this is not
|
||||||
@@ -468,63 +468,63 @@ of `K` seconds to still converge when `J <= K`, as long as `I > J || I > K`,
|
|||||||
which is another way of saying that if the resource finally settles down to give
|
which is another way of saying that if the resource finally settles down to give
|
||||||
the graph enough time, it can probably converge.
|
the graph enough time, it can probably converge.
|
||||||
|
|
||||||
###Graph definition file
|
### Graph definition file
|
||||||
graph.yaml is the compiled graph definition file. The format is currently
|
graph.yaml is the compiled graph definition file. The format is currently
|
||||||
undocumented, but by looking through the [examples/](https://github.com/purpleidea/mgmt/tree/master/examples)
|
undocumented, but by looking through the [examples/](https://github.com/purpleidea/mgmt/tree/master/examples)
|
||||||
you can probably figure out most of it, as it's fairly intuitive.
|
you can probably figure out most of it, as it's fairly intuitive.
|
||||||
|
|
||||||
###Command line
|
### Command line
|
||||||
The main interface to the `mgmt` tool is the command line. For the most recent
|
The main interface to the `mgmt` tool is the command line. For the most recent
|
||||||
documentation, please run `mgmt --help`.
|
documentation, please run `mgmt --help`.
|
||||||
|
|
||||||
####`--yaml <graph.yaml>`
|
#### `--yaml <graph.yaml>`
|
||||||
Point to a graph file to run.
|
Point to a graph file to run.
|
||||||
|
|
||||||
####`--converged-timeout <seconds>`
|
#### `--converged-timeout <seconds>`
|
||||||
Exit if the machine has converged for approximately this many seconds.
|
Exit if the machine has converged for approximately this many seconds.
|
||||||
|
|
||||||
####`--max-runtime <seconds>`
|
#### `--max-runtime <seconds>`
|
||||||
Exit when the agent has run for approximately this many seconds. This is not
|
Exit when the agent has run for approximately this many seconds. This is not
|
||||||
generally recommended, but may be useful for users who know what they're doing.
|
generally recommended, but may be useful for users who know what they're doing.
|
||||||
|
|
||||||
####`--noop`
|
#### `--noop`
|
||||||
Globally force all resources into no-op mode. This also disables the export to
|
Globally force all resources into no-op mode. This also disables the export to
|
||||||
etcd functionality, but does not disable resource collection, however all
|
etcd functionality, but does not disable resource collection, however all
|
||||||
resources that are collected will have their individual noop settings set.
|
resources that are collected will have their individual noop settings set.
|
||||||
|
|
||||||
####`--remote <graph.yaml>`
|
#### `--remote <graph.yaml>`
|
||||||
Point to a graph file to run on the remote host specified within. This parameter
|
Point to a graph file to run on the remote host specified within. This parameter
|
||||||
can be used multiple times if you'd like to remotely run on multiple hosts in
|
can be used multiple times if you'd like to remotely run on multiple hosts in
|
||||||
parallel.
|
parallel.
|
||||||
|
|
||||||
####`--allow-interactive`
|
#### `--allow-interactive`
|
||||||
Allow interactive prompting for SSH passwords if there is no authentication
|
Allow interactive prompting for SSH passwords if there is no authentication
|
||||||
method that works.
|
method that works.
|
||||||
|
|
||||||
####`--ssh-priv-id-rsa`
|
#### `--ssh-priv-id-rsa`
|
||||||
Specify the path for finding SSH keys. This defaults to `~/.ssh/id_rsa`. To
|
Specify the path for finding SSH keys. This defaults to `~/.ssh/id_rsa`. To
|
||||||
never use this method of authentication, set this to the empty string.
|
never use this method of authentication, set this to the empty string.
|
||||||
|
|
||||||
####`--cconns`
|
#### `--cconns`
|
||||||
The maximum number of concurrent remote ssh connections to run. This defaults
|
The maximum number of concurrent remote ssh connections to run. This defaults
|
||||||
to `0`, which means unlimited.
|
to `0`, which means unlimited.
|
||||||
|
|
||||||
####`--no-caching`
|
#### `--no-caching`
|
||||||
Don't allow remote caching of the remote execution binary. This will require
|
Don't allow remote caching of the remote execution binary. This will require
|
||||||
the binary to be copied over for every remote execution, but it limits the
|
the binary to be copied over for every remote execution, but it limits the
|
||||||
likelihood that there is leftover information from the configuration process.
|
likelihood that there is leftover information from the configuration process.
|
||||||
|
|
||||||
####`--prefix <path>`
|
#### `--prefix <path>`
|
||||||
Specify a path to a custom working directory prefix. This directory will get
|
Specify a path to a custom working directory prefix. This directory will get
|
||||||
created if it does not exist. This usually defaults to `/var/lib/mgmt/`. This
|
created if it does not exist. This usually defaults to `/var/lib/mgmt/`. This
|
||||||
can't be combined with the `--tmp-prefix` option. It can be combined with the
|
can't be combined with the `--tmp-prefix` option. It can be combined with the
|
||||||
`--allow-tmp-prefix` option.
|
`--allow-tmp-prefix` option.
|
||||||
|
|
||||||
####`--tmp-prefix`
|
#### `--tmp-prefix`
|
||||||
If this option is specified, a temporary prefix will be used instead of the
|
If this option is specified, a temporary prefix will be used instead of the
|
||||||
default prefix. This can't be combined with the `--prefix` option.
|
default prefix. This can't be combined with the `--prefix` option.
|
||||||
|
|
||||||
####`--allow-tmp-prefix`
|
#### `--allow-tmp-prefix`
|
||||||
If this option is specified, we will attempt to fall back to a temporary prefix
|
If this option is specified, we will attempt to fall back to a temporary prefix
|
||||||
if the primary prefix couldn't be created. This is useful for avoiding failures
|
if the primary prefix couldn't be created. This is useful for avoiding failures
|
||||||
in environments where the primary prefix may or may not be available, but you'd
|
in environments where the primary prefix may or may not be available, but you'd
|
||||||
@@ -532,7 +532,7 @@ like to try. The canonical example is when running `mgmt` with `--remote` there
|
|||||||
might be a cached copy of the binary in the primary prefix, but in case there's
|
might be a cached copy of the binary in the primary prefix, but in case there's
|
||||||
no binary available continue working in a temporary directory to avoid failure.
|
no binary available continue working in a temporary directory to avoid failure.
|
||||||
|
|
||||||
##Examples
|
## Examples
|
||||||
For example configurations, please consult the [examples/](https://github.com/purpleidea/mgmt/tree/master/examples) directory in the git
|
For example configurations, please consult the [examples/](https://github.com/purpleidea/mgmt/tree/master/examples) directory in the git
|
||||||
source repository. It is available from:
|
source repository. It is available from:
|
||||||
|
|
||||||
@@ -560,7 +560,7 @@ EOF
|
|||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
```
|
```
|
||||||
|
|
||||||
##Development
|
## Development
|
||||||
|
|
||||||
This is a project that I started in my free time in 2013. Development is driven
|
This is a project that I started in my free time in 2013. Development is driven
|
||||||
by all of our collective patches! Dive right in, and start hacking!
|
by all of our collective patches! Dive right in, and start hacking!
|
||||||
@@ -570,7 +570,7 @@ You can follow along [on my technical blog](https://ttboj.wordpress.com/).
|
|||||||
|
|
||||||
To report any bugs, please file a ticket at: [https://github.com/purpleidea/mgmt/issues](https://github.com/purpleidea/mgmt/issues).
|
To report any bugs, please file a ticket at: [https://github.com/purpleidea/mgmt/issues](https://github.com/purpleidea/mgmt/issues).
|
||||||
|
|
||||||
##Authors
|
## Authors
|
||||||
|
|
||||||
Copyright (C) 2013-2016+ James Shubin and the project contributors
|
Copyright (C) 2013-2016+ James Shubin and the project contributors
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#mgmt
|
# mgmt
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Mgmt
|
Mgmt
|
||||||
@@ -19,13 +19,13 @@ You should have received a copy of the GNU Affero General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
##mgmt Puppet guide
|
## mgmt Puppet guide
|
||||||
####Available from:
|
#### Available from:
|
||||||
####[https://github.com/purpleidea/mgmt/](https://github.com/purpleidea/mgmt/)
|
#### [https://github.com/purpleidea/mgmt/](https://github.com/purpleidea/mgmt/)
|
||||||
|
|
||||||
####This documentation is available in: [Markdown](https://github.com/purpleidea/mgmt/blob/master/docs/puppet-guide.md) or [PDF](https://pdfdoc-purpleidea.rhcloud.com/pdf/https://github.com/purpleidea/mgmt/blob/master/docs/puppet-guide.md) format.
|
#### This documentation is available in: [Markdown](https://github.com/purpleidea/mgmt/blob/master/docs/puppet-guide.md) or [PDF](https://pdfdoc-purpleidea.rhcloud.com/pdf/https://github.com/purpleidea/mgmt/blob/master/docs/puppet-guide.md) format.
|
||||||
|
|
||||||
####Table of Contents
|
#### Table of Contents
|
||||||
|
|
||||||
1. [Prerequisites](#prerequisites)
|
1. [Prerequisites](#prerequisites)
|
||||||
* [Testing the Puppet side](#testing-the-puppet-side)
|
* [Testing the Puppet side](#testing-the-puppet-side)
|
||||||
@@ -43,7 +43,7 @@ some pitfalls and limitations.
|
|||||||
For basic instructions on how to use the Puppet support, see
|
For basic instructions on how to use the Puppet support, see
|
||||||
the [main documentation](documentation.md#puppet-support).
|
the [main documentation](documentation.md#puppet-support).
|
||||||
|
|
||||||
##Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
You need Puppet installed in your system. It is not important how you
|
You need Puppet installed in your system. It is not important how you
|
||||||
get it. On the most common Linux distributions, you can use packages
|
get it. On the most common Linux distributions, you can use packages
|
||||||
@@ -65,7 +65,7 @@ use a master/agent setup). It's needed on the machine that runs `mgmt`.
|
|||||||
You can install the module on the master anyway, so that it gets distributed
|
You can install the module on the master anyway, so that it gets distributed
|
||||||
to your agents through Puppet's `pluginsync` mechanism.
|
to your agents through Puppet's `pluginsync` mechanism.
|
||||||
|
|
||||||
###Testing the Puppet side
|
### Testing the Puppet side
|
||||||
|
|
||||||
The following command should run successfully and print a YAML hash on your
|
The following command should run successfully and print a YAML hash on your
|
||||||
terminal:
|
terminal:
|
||||||
@@ -77,9 +77,9 @@ puppet mgmtgraph print --code 'file { "/tmp/mgmt-test": ensure => present }'
|
|||||||
You can use this CLI to test any manifests before handing them straight
|
You can use this CLI to test any manifests before handing them straight
|
||||||
to `mgmt`.
|
to `mgmt`.
|
||||||
|
|
||||||
##Writing a suitable manifest
|
## Writing a suitable manifest
|
||||||
|
|
||||||
###Unsupported attributes
|
### Unsupported attributes
|
||||||
|
|
||||||
`mgmt` inherited its resource module from Puppet, so by and large, it's quite
|
`mgmt` inherited its resource module from Puppet, so by and large, it's quite
|
||||||
possible to express `mgmt` graphs in terms of Puppet manifests. However,
|
possible to express `mgmt` graphs in terms of Puppet manifests. However,
|
||||||
@@ -102,7 +102,7 @@ in fact not pass this information to the `/tmp/foo` file resource, and
|
|||||||
manifests that are written expressly for `mgmt` is not sensible and should
|
manifests that are written expressly for `mgmt` is not sensible and should
|
||||||
be avoided.
|
be avoided.
|
||||||
|
|
||||||
###Unsupported resources
|
### Unsupported resources
|
||||||
|
|
||||||
Puppet has a fairly large number of
|
Puppet has a fairly large number of
|
||||||
[built-in types](https://docs.puppet.com/puppet/latest/reference/type.html),
|
[built-in types](https://docs.puppet.com/puppet/latest/reference/type.html),
|
||||||
@@ -122,7 +122,7 @@ this overhead can amount to several orders of magnitude.
|
|||||||
|
|
||||||
Avoid Puppet types that `mgmt` does not implement (yet).
|
Avoid Puppet types that `mgmt` does not implement (yet).
|
||||||
|
|
||||||
###Avoiding common warnings
|
### Avoiding common warnings
|
||||||
|
|
||||||
Many resource parameters in Puppet take default values. For the most part,
|
Many resource parameters in Puppet take default values. For the most part,
|
||||||
the translator module just ignores them. However, there are cases in which
|
the translator module just ignores them. However, there are cases in which
|
||||||
@@ -160,7 +160,7 @@ File { backup => false }
|
|||||||
If you encounter similar warnings from other types and/or parameters,
|
If you encounter similar warnings from other types and/or parameters,
|
||||||
use the same approach to silence them if possible.
|
use the same approach to silence them if possible.
|
||||||
|
|
||||||
##Configuring Puppet
|
## Configuring Puppet
|
||||||
|
|
||||||
Since `mgmt` uses an actual Puppet CLI behind the scenes, you might
|
Since `mgmt` uses an actual Puppet CLI behind the scenes, you might
|
||||||
need to tweak some of Puppet's runtime options in order to make it
|
need to tweak some of Puppet's runtime options in order to make it
|
||||||
@@ -191,7 +191,7 @@ server=mgmt-master.example.net
|
|||||||
vardir=/var/lib/mgmt/puppet
|
vardir=/var/lib/mgmt/puppet
|
||||||
```
|
```
|
||||||
|
|
||||||
##Caveats
|
## Caveats
|
||||||
|
|
||||||
Please see the [README](https://github.com/ffrank/puppet-mgmtgraph/blob/master/README.md)
|
Please see the [README](https://github.com/ffrank/puppet-mgmtgraph/blob/master/README.md)
|
||||||
of the translator module for the current state of supported and unsupported
|
of the translator module for the current state of supported and unsupported
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#mgmt
|
# mgmt
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Mgmt
|
Mgmt
|
||||||
@@ -19,13 +19,13 @@ You should have received a copy of the GNU Affero General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
##mgmt quick start guide
|
## mgmt quick start guide
|
||||||
####Available from:
|
#### Available from:
|
||||||
####[https://github.com/purpleidea/mgmt/](https://github.com/purpleidea/mgmt/)
|
#### [https://github.com/purpleidea/mgmt/](https://github.com/purpleidea/mgmt/)
|
||||||
|
|
||||||
####This documentation is available in: [Markdown](https://github.com/purpleidea/mgmt/blob/master/docs/quick-start-guide.md) or [PDF](https://pdfdoc-purpleidea.rhcloud.com/pdf/https://github.com/purpleidea/mgmt/blob/master/docs/quick-start-guide.md) format.
|
#### This documentation is available in: [Markdown](https://github.com/purpleidea/mgmt/blob/master/docs/quick-start-guide.md) or [PDF](https://pdfdoc-purpleidea.rhcloud.com/pdf/https://github.com/purpleidea/mgmt/blob/master/docs/quick-start-guide.md) format.
|
||||||
|
|
||||||
####Table of Contents
|
#### Table of Contents
|
||||||
|
|
||||||
0. [Introduction](#introduction)
|
0. [Introduction](#introduction)
|
||||||
1. [Dependencies](#dependencies)
|
1. [Dependencies](#dependencies)
|
||||||
@@ -65,7 +65,7 @@ golang.org/x/tools/cmd/stringer
|
|||||||
```
|
```
|
||||||
* `pandoc` (optional), for building a pdf of the documentation
|
* `pandoc` (optional), for building a pdf of the documentation
|
||||||
|
|
||||||
###Runtime
|
### Runtime
|
||||||
A relatively modern GNU/Linux system should be able to run `mgmt` without any
|
A relatively modern GNU/Linux system should be able to run `mgmt` without any
|
||||||
problems. Since `mgmt` runs as a single statically compiled binary, all of the
|
problems. Since `mgmt` runs as a single statically compiled binary, all of the
|
||||||
library dependencies are included. It is expected, that certain advanced
|
library dependencies are included. It is expected, that certain advanced
|
||||||
@@ -83,7 +83,7 @@ listed below:
|
|||||||
|
|
||||||
For building a visual representation of the graph, `graphviz` is required.
|
For building a visual representation of the graph, `graphviz` is required.
|
||||||
|
|
||||||
###Testing
|
### Testing
|
||||||
* golint `github.com/golang/lint/golint`
|
* golint `github.com/golang/lint/golint`
|
||||||
|
|
||||||
## Quick start:
|
## Quick start:
|
||||||
@@ -117,7 +117,7 @@ At the moment we have:
|
|||||||
|
|
||||||
Please contribute more! We'd especially like to see a Debian package!
|
Please contribute more! We'd especially like to see a Debian package!
|
||||||
|
|
||||||
##Authors
|
## Authors
|
||||||
Copyright (C) 2013-2016+ James Shubin and the project contributors
|
Copyright (C) 2013-2016+ James Shubin and the project contributors
|
||||||
|
|
||||||
Please see the
|
Please see the
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#mgmt
|
# mgmt
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Mgmt
|
Mgmt
|
||||||
@@ -19,13 +19,13 @@ You should have received a copy of the GNU Affero General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
##mgmt resource guide by [James](https://ttboj.wordpress.com/)
|
## mgmt resource guide by [James](https://ttboj.wordpress.com/)
|
||||||
####Available from:
|
#### Available from:
|
||||||
####[https://github.com/purpleidea/mgmt/](https://github.com/purpleidea/mgmt/)
|
#### [https://github.com/purpleidea/mgmt/](https://github.com/purpleidea/mgmt/)
|
||||||
|
|
||||||
####This documentation is available in: [Markdown](https://github.com/purpleidea/mgmt/blob/master/docs/resource-guide.md) or [PDF](https://pdfdoc-purpleidea.rhcloud.com/pdf/https://github.com/purpleidea/mgmt/blob/master/docs/resource-guide.md) format.
|
#### This documentation is available in: [Markdown](https://github.com/purpleidea/mgmt/blob/master/docs/resource-guide.md) or [PDF](https://pdfdoc-purpleidea.rhcloud.com/pdf/https://github.com/purpleidea/mgmt/blob/master/docs/resource-guide.md) format.
|
||||||
|
|
||||||
####Table of Contents
|
#### Table of Contents
|
||||||
|
|
||||||
1. [Overview](#overview)
|
1. [Overview](#overview)
|
||||||
2. [Theory - Resource theory in mgmt](#theory)
|
2. [Theory - Resource theory in mgmt](#theory)
|
||||||
@@ -49,7 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
10. [Suggestions - API change suggestions](#suggestions)
|
10. [Suggestions - API change suggestions](#suggestions)
|
||||||
11. [Authors - Authors and contact information](#authors)
|
11. [Authors - Authors and contact information](#authors)
|
||||||
|
|
||||||
##Overview
|
## Overview
|
||||||
|
|
||||||
The `mgmt` tool has built-in resource primitives which make up the building
|
The `mgmt` tool has built-in resource primitives which make up the building
|
||||||
blocks of any configuration. Each instance of a resource is mapped to a single
|
blocks of any configuration. Each instance of a resource is mapped to a single
|
||||||
@@ -58,7 +58,7 @@ This guide is meant to instruct developers on how to write a brand new resource.
|
|||||||
Since `mgmt` and the core resources are written in golang, some prior golang
|
Since `mgmt` and the core resources are written in golang, some prior golang
|
||||||
knowledge is assumed.
|
knowledge is assumed.
|
||||||
|
|
||||||
##Theory
|
## Theory
|
||||||
|
|
||||||
Resources in `mgmt` are similar to resources in other systems in that they are
|
Resources in `mgmt` are similar to resources in other systems in that they are
|
||||||
[idempotent](https://en.wikipedia.org/wiki/Idempotence). Our resources are
|
[idempotent](https://en.wikipedia.org/wiki/Idempotence). Our resources are
|
||||||
@@ -68,14 +68,14 @@ on this design, please read the
|
|||||||
[original article](https://ttboj.wordpress.com/2016/01/18/next-generation-configuration-mgmt/)
|
[original article](https://ttboj.wordpress.com/2016/01/18/next-generation-configuration-mgmt/)
|
||||||
on the subject.
|
on the subject.
|
||||||
|
|
||||||
##Resource API
|
## Resource API
|
||||||
|
|
||||||
To implement a resource in `mgmt` it must satisfy the
|
To implement a resource in `mgmt` it must satisfy the
|
||||||
[`Res`](https://github.com/purpleidea/mgmt/blob/master/resources/resources.go)
|
[`Res`](https://github.com/purpleidea/mgmt/blob/master/resources/resources.go)
|
||||||
interface. What follows are each of the method signatures and a description of
|
interface. What follows are each of the method signatures and a description of
|
||||||
each.
|
each.
|
||||||
|
|
||||||
###Default
|
### Default
|
||||||
```golang
|
```golang
|
||||||
Default() Res
|
Default() Res
|
||||||
```
|
```
|
||||||
@@ -84,7 +84,7 @@ This returns a populated resource struct as a `Res`. It shouldn't populate any
|
|||||||
values which already have the correct default as the golang zero value. In
|
values which already have the correct default as the golang zero value. In
|
||||||
general it is preferable if the zero values make for the correct defaults.
|
general it is preferable if the zero values make for the correct defaults.
|
||||||
|
|
||||||
####Example
|
#### Example
|
||||||
```golang
|
```golang
|
||||||
// Default returns some sensible defaults for this resource.
|
// Default returns some sensible defaults for this resource.
|
||||||
func (obj *FooRes) Default() Res {
|
func (obj *FooRes) Default() Res {
|
||||||
@@ -94,7 +94,7 @@ func (obj *FooRes) Default() Res {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
###Validate
|
### Validate
|
||||||
```golang
|
```golang
|
||||||
Validate() error
|
Validate() error
|
||||||
```
|
```
|
||||||
@@ -105,7 +105,7 @@ specifications, it should generate an error. If you notice that this method is
|
|||||||
quite large, it might be an indication that you should reconsider the parameter
|
quite large, it might be an indication that you should reconsider the parameter
|
||||||
list and interface to this resource. This method is called _before_ `Init`.
|
list and interface to this resource. This method is called _before_ `Init`.
|
||||||
|
|
||||||
###Init
|
### Init
|
||||||
```golang
|
```golang
|
||||||
Init() error
|
Init() error
|
||||||
```
|
```
|
||||||
@@ -114,7 +114,7 @@ This is called to initialize the resource. If something goes wrong, it should
|
|||||||
return an error. It should set the resource `kind`, do any resource specific
|
return an error. It should set the resource `kind`, do any resource specific
|
||||||
work, and finish by calling the `Init` method of the base resource.
|
work, and finish by calling the `Init` method of the base resource.
|
||||||
|
|
||||||
####Example
|
#### Example
|
||||||
```golang
|
```golang
|
||||||
// Init initializes the Foo resource.
|
// Init initializes the Foo resource.
|
||||||
func (obj *FooRes) Init() error {
|
func (obj *FooRes) Init() error {
|
||||||
@@ -133,7 +133,7 @@ this. In other words, you should expect `Validate` to have run first, but you
|
|||||||
shouldn't allow `Init` to dangerously `rm -rf /$the_world` if your code only
|
shouldn't allow `Init` to dangerously `rm -rf /$the_world` if your code only
|
||||||
checks `$the_world` in `Validate`. Remember to always program safely!
|
checks `$the_world` in `Validate`. Remember to always program safely!
|
||||||
|
|
||||||
###CheckApply
|
### CheckApply
|
||||||
```golang
|
```golang
|
||||||
CheckApply(apply bool) (checkOK bool, err error)
|
CheckApply(apply bool) (checkOK bool, err error)
|
||||||
```
|
```
|
||||||
@@ -158,7 +158,7 @@ resource isn't now converged. This is not a bug, as the resources `Watch`
|
|||||||
facility will detect the change, ultimately resulting in a subsequent call to
|
facility will detect the change, ultimately resulting in a subsequent call to
|
||||||
`CheckApply`.
|
`CheckApply`.
|
||||||
|
|
||||||
####Example
|
#### Example
|
||||||
```golang
|
```golang
|
||||||
// CheckApply does the idempotent work of checking and applying resource state.
|
// CheckApply does the idempotent work of checking and applying resource state.
|
||||||
func (obj *FooRes) CheckApply(apply bool) (bool, error) {
|
func (obj *FooRes) CheckApply(apply bool) (bool, error) {
|
||||||
@@ -179,7 +179,7 @@ skipped. This is an engine optimization, and not a bug. It is mentioned here in
|
|||||||
the documentation in case you are confused as to why a debug message you've
|
the documentation in case you are confused as to why a debug message you've
|
||||||
added to the code isn't always printed.
|
added to the code isn't always printed.
|
||||||
|
|
||||||
####Refresh notifications
|
#### Refresh notifications
|
||||||
Some resources may choose to support receiving refresh notifications. In general
|
Some resources may choose to support receiving refresh notifications. In general
|
||||||
these should be avoided if possible, but nevertheless, they do make sense in
|
these should be avoided if possible, but nevertheless, they do make sense in
|
||||||
certain situations. Resources that support these need to verify if one was sent
|
certain situations. Resources that support these need to verify if one was sent
|
||||||
@@ -192,7 +192,7 @@ action is applied by that resource and are transmitted through graph edges which
|
|||||||
have enabled their propagation. Resources that currently perform some refresh
|
have enabled their propagation. Resources that currently perform some refresh
|
||||||
action include `svc`, `timer`, and `password`.
|
action include `svc`, `timer`, and `password`.
|
||||||
|
|
||||||
####Paired execution
|
#### Paired execution
|
||||||
For many resources it is not uncommon to see `CheckApply` run twice in rapid
|
For many resources it is not uncommon to see `CheckApply` run twice in rapid
|
||||||
succession. This is usually not a pathological occurrence, but rather a healthy
|
succession. This is usually not a pathological occurrence, but rather a healthy
|
||||||
pattern which is a consequence of the event system. When the state of the
|
pattern which is a consequence of the event system. When the state of the
|
||||||
@@ -201,14 +201,14 @@ having just changed the state, it is usually the case that this repair will
|
|||||||
trigger the `Watch` code! In response, a second `CheckApply` is triggered, which
|
trigger the `Watch` code! In response, a second `CheckApply` is triggered, which
|
||||||
will likely find the state to now be correct.
|
will likely find the state to now be correct.
|
||||||
|
|
||||||
####Summary
|
#### Summary
|
||||||
* Anytime an error occurs during `CheckApply`, you should return `(false, err)`.
|
* Anytime an error occurs during `CheckApply`, you should return `(false, err)`.
|
||||||
* If the state is correct and no changes are needed, return `(true, nil)`.
|
* If the state is correct and no changes are needed, return `(true, nil)`.
|
||||||
* You should only make changes to the system if `apply` is set to `true`.
|
* You should only make changes to the system if `apply` is set to `true`.
|
||||||
* After checking the state and possibly applying the fix, return `(false, nil)`.
|
* After checking the state and possibly applying the fix, return `(false, nil)`.
|
||||||
* Returning `(true, err)` is a programming error and will cause a `Fatal`.
|
* Returning `(true, err)` is a programming error and will cause a `Fatal`.
|
||||||
|
|
||||||
###Watch
|
### Watch
|
||||||
```golang
|
```golang
|
||||||
Watch(chan Event) error
|
Watch(chan Event) error
|
||||||
```
|
```
|
||||||
@@ -237,7 +237,7 @@ If the resource is activated in `polling` mode, the `Watch` method will not get
|
|||||||
executed. As a result, the resource must still work even if the main loop is not
|
executed. As a result, the resource must still work even if the main loop is not
|
||||||
running.
|
running.
|
||||||
|
|
||||||
####Select
|
#### Select
|
||||||
The lifetime of most resources `Watch` method should be spent in an infinite
|
The lifetime of most resources `Watch` method should be spent in an infinite
|
||||||
loop that is bounded by a `select` call. The `select` call is the point where
|
loop that is bounded by a `select` call. The `select` call is the point where
|
||||||
our method hands back control to the engine (and the kernel) so that we can
|
our method hands back control to the engine (and the kernel) so that we can
|
||||||
@@ -246,7 +246,7 @@ events from the engine via the `<-obj.Events()` call, wait for the converged
|
|||||||
timeout with `<-cuid.ConvergedTimer()`, and receive events for our resource
|
timeout with `<-cuid.ConvergedTimer()`, and receive events for our resource
|
||||||
itself!
|
itself!
|
||||||
|
|
||||||
####Events
|
#### Events
|
||||||
If we receive an internal event from the `<-obj.Events()` method, we can read it
|
If we receive an internal event from the `<-obj.Events()` method, we can read it
|
||||||
with the ReadEvent helper function. This function tells us if we should shutdown
|
with the ReadEvent helper function. This function tells us if we should shutdown
|
||||||
our resource, and if we should generate an event. When we want to send an event,
|
our resource, and if we should generate an event. When we want to send an event,
|
||||||
@@ -254,14 +254,14 @@ we use the `DoSend` helper function. It is also important to mark the resource
|
|||||||
state as `dirty` if we believe it might have changed. We do this with the
|
state as `dirty` if we believe it might have changed. We do this with the
|
||||||
`StateOK(false)` function.
|
`StateOK(false)` function.
|
||||||
|
|
||||||
####Startup
|
#### Startup
|
||||||
Once the `Watch` function has finished starting up successfully, it is important
|
Once the `Watch` function has finished starting up successfully, it is important
|
||||||
to generate one event to notify the `mgmt` engine that we're now listening
|
to generate one event to notify the `mgmt` engine that we're now listening
|
||||||
successfully, so that it can run an initial `CheckApply` to ensure we're safely
|
successfully, so that it can run an initial `CheckApply` to ensure we're safely
|
||||||
tracking a healthy state and that we didn't miss anything when `Watch` was down
|
tracking a healthy state and that we didn't miss anything when `Watch` was down
|
||||||
or from before `mgmt` was running. It does this by calling the `Running` method.
|
or from before `mgmt` was running. It does this by calling the `Running` method.
|
||||||
|
|
||||||
####Converged
|
#### Converged
|
||||||
The engine might be asked to shutdown when the entire state of the system has
|
The engine might be asked to shutdown when the entire state of the system has
|
||||||
not seen any changes for some duration of time. In order for the engine to be
|
not seen any changes for some duration of time. In order for the engine to be
|
||||||
able to make this determination, each resource must report its converged state.
|
able to make this determination, each resource must report its converged state.
|
||||||
@@ -275,7 +275,7 @@ Instead of interacting with the `ConvergedUID` with these two methods, we can
|
|||||||
instead use the `StartTimer` and `ResetTimer` methods which accomplish the same
|
instead use the `StartTimer` and `ResetTimer` methods which accomplish the same
|
||||||
thing, but provide a `select`-free interface for different coding situations.
|
thing, but provide a `select`-free interface for different coding situations.
|
||||||
|
|
||||||
####Example
|
#### Example
|
||||||
```golang
|
```golang
|
||||||
// Watch is the listener and main loop for this resource.
|
// Watch is the listener and main loop for this resource.
|
||||||
func (obj *FooRes) Watch(processChan chan event.Event) error {
|
func (obj *FooRes) Watch(processChan chan event.Event) error {
|
||||||
@@ -334,14 +334,14 @@ func (obj *FooRes) Watch(processChan chan event.Event) error {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
####Summary
|
#### Summary
|
||||||
* Remember to call the appropriate `converger` methods throughout the resource.
|
* Remember to call the appropriate `converger` methods throughout the resource.
|
||||||
* Remember to call `Startup` when the `Watch` is running successfully.
|
* Remember to call `Startup` when the `Watch` is running successfully.
|
||||||
* Remember to process internal events and shutdown promptly if asked to.
|
* Remember to process internal events and shutdown promptly if asked to.
|
||||||
* Ensure the design of your resource is well thought out.
|
* Ensure the design of your resource is well thought out.
|
||||||
* Have a look at the existing resources for a rough idea of how this all works.
|
* Have a look at the existing resources for a rough idea of how this all works.
|
||||||
|
|
||||||
###Compare
|
### Compare
|
||||||
```golang
|
```golang
|
||||||
Compare(Res) bool
|
Compare(Res) bool
|
||||||
```
|
```
|
||||||
@@ -358,7 +358,7 @@ need to be changed. On occasion, not all of them need to be compared, in
|
|||||||
particular if they store some generated state, or if they aren't significant in
|
particular if they store some generated state, or if they aren't significant in
|
||||||
some way.
|
some way.
|
||||||
|
|
||||||
####Example
|
#### Example
|
||||||
```golang
|
```golang
|
||||||
// Compare two resources and return if they are equivalent.
|
// Compare two resources and return if they are equivalent.
|
||||||
func (obj *FooRes) Compare(res Res) bool {
|
func (obj *FooRes) Compare(res Res) bool {
|
||||||
@@ -384,7 +384,7 @@ func (obj *FooRes) Compare(res Res) bool {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
###GetUIDs
|
### GetUIDs
|
||||||
```golang
|
```golang
|
||||||
GetUIDs() []ResUID
|
GetUIDs() []ResUID
|
||||||
```
|
```
|
||||||
@@ -393,7 +393,7 @@ The `GetUIDs` method returns a list of `ResUID` interfaces that represent the
|
|||||||
particular resource uniquely. This is used with the AutoEdges API to determine
|
particular resource uniquely. This is used with the AutoEdges API to determine
|
||||||
if another resource can match a dependency to this one.
|
if another resource can match a dependency to this one.
|
||||||
|
|
||||||
###AutoEdges
|
### AutoEdges
|
||||||
```golang
|
```golang
|
||||||
AutoEdges() AutoEdge
|
AutoEdges() AutoEdge
|
||||||
```
|
```
|
||||||
@@ -402,14 +402,14 @@ This returns a struct that implements the `AutoEdge` interface. This struct
|
|||||||
is used to match other resources that might be relevant dependencies for this
|
is used to match other resources that might be relevant dependencies for this
|
||||||
resource.
|
resource.
|
||||||
|
|
||||||
###CollectPattern
|
### CollectPattern
|
||||||
```golang
|
```golang
|
||||||
CollectPattern() string
|
CollectPattern() string
|
||||||
```
|
```
|
||||||
|
|
||||||
This is currently a stub and will be updated once the DSL is further along.
|
This is currently a stub and will be updated once the DSL is further along.
|
||||||
|
|
||||||
###UnmarshalYAML
|
### UnmarshalYAML
|
||||||
```golang
|
```golang
|
||||||
UnmarshalYAML(unmarshal func(interface{}) error) error // optional
|
UnmarshalYAML(unmarshal func(interface{}) error) error // optional
|
||||||
```
|
```
|
||||||
@@ -422,7 +422,7 @@ someone writes to use with `libmgmt`) would have to implement this needlessly.
|
|||||||
The signature intentionally matches what is required to satisfy the `go-yaml`
|
The signature intentionally matches what is required to satisfy the `go-yaml`
|
||||||
[Unmarshaler](https://godoc.org/gopkg.in/yaml.v2#Unmarshaler) interface.
|
[Unmarshaler](https://godoc.org/gopkg.in/yaml.v2#Unmarshaler) interface.
|
||||||
|
|
||||||
####Example
|
#### Example
|
||||||
```golang
|
```golang
|
||||||
// UnmarshalYAML is the custom unmarshal handler for this struct.
|
// UnmarshalYAML is the custom unmarshal handler for this struct.
|
||||||
// It is primarily useful for setting the defaults.
|
// It is primarily useful for setting the defaults.
|
||||||
@@ -445,18 +445,18 @@ func (obj *FooRes) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
##Further considerations
|
## Further considerations
|
||||||
There is some additional information that any resource writer will need to know.
|
There is some additional information that any resource writer will need to know.
|
||||||
Each issue is listed separately below!
|
Each issue is listed separately below!
|
||||||
|
|
||||||
###Resource struct
|
### Resource struct
|
||||||
Each resource will implement methods as pointer receivers on a resource struct.
|
Each resource will implement methods as pointer receivers on a resource struct.
|
||||||
The resource struct must include an anonymous reference to the `BaseRes` struct.
|
The resource struct must include an anonymous reference to the `BaseRes` struct.
|
||||||
The naming convention for resources is that they end with a `Res` suffix. If
|
The naming convention for resources is that they end with a `Res` suffix. If
|
||||||
you'd like your resource to be accessible by the `YAML` graph API (GAPI), then
|
you'd like your resource to be accessible by the `YAML` graph API (GAPI), then
|
||||||
you'll need to include the appropriate YAML fields as shown below.
|
you'll need to include the appropriate YAML fields as shown below.
|
||||||
|
|
||||||
####Example
|
#### Example
|
||||||
```golang
|
```golang
|
||||||
type FooRes struct {
|
type FooRes struct {
|
||||||
BaseRes `yaml:",inline"` // base properties
|
BaseRes `yaml:",inline"` // base properties
|
||||||
@@ -469,7 +469,7 @@ type FooRes struct {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
###YAML
|
### YAML
|
||||||
In addition to labelling your resource struct with YAML fields, you must also
|
In addition to labelling your resource struct with YAML fields, you must also
|
||||||
add an entry to the internal `GraphConfig` struct. It is a fairly straight
|
add an entry to the internal `GraphConfig` struct. It is a fairly straight
|
||||||
forward one line patch.
|
forward one line patch.
|
||||||
@@ -489,7 +489,7 @@ type GraphConfig struct {
|
|||||||
It's also recommended that you add the [UnmarshalYAML](#unmarshalyaml) method to
|
It's also recommended that you add the [UnmarshalYAML](#unmarshalyaml) method to
|
||||||
your resources so that unspecified values are given sane defaults.
|
your resources so that unspecified values are given sane defaults.
|
||||||
|
|
||||||
###Gob registration
|
### Gob registration
|
||||||
All resources must be registered with the `golang` _gob_ module so that they can
|
All resources must be registered with the `golang` _gob_ module so that they can
|
||||||
be encoded and decoded. Make sure to include the following code snippet for this
|
be encoded and decoded. Make sure to include the following code snippet for this
|
||||||
to work.
|
to work.
|
||||||
@@ -501,14 +501,14 @@ func init() { // special golang method that runs once
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
##Automatic edges
|
## Automatic edges
|
||||||
Automatic edges in `mgmt` are well described in [this article](https://ttboj.wordpress.com/2016/03/14/automatic-edges-in-mgmt/).
|
Automatic edges in `mgmt` are well described in [this article](https://ttboj.wordpress.com/2016/03/14/automatic-edges-in-mgmt/).
|
||||||
The best example of this technique can be seen in the `svc` resource.
|
The best example of this technique can be seen in the `svc` resource.
|
||||||
Unfortunately no further documentation about this subject has been written. To
|
Unfortunately no further documentation about this subject has been written. To
|
||||||
expand this section, please send a patch! Please contact us if you'd like to
|
expand this section, please send a patch! Please contact us if you'd like to
|
||||||
work on a resource that uses this feature, or to add it to an existing one!
|
work on a resource that uses this feature, or to add it to an existing one!
|
||||||
|
|
||||||
##Automatic grouping
|
## Automatic grouping
|
||||||
Automatic grouping in `mgmt` is well described in [this article](https://ttboj.wordpress.com/2016/03/30/automatic-grouping-in-mgmt/).
|
Automatic grouping in `mgmt` is well described in [this article](https://ttboj.wordpress.com/2016/03/30/automatic-grouping-in-mgmt/).
|
||||||
The best example of this technique can be seen in the `pkg` resource.
|
The best example of this technique can be seen in the `pkg` resource.
|
||||||
Unfortunately no further documentation about this subject has been written. To
|
Unfortunately no further documentation about this subject has been written. To
|
||||||
@@ -516,7 +516,7 @@ expand this section, please send a patch! Please contact us if you'd like to
|
|||||||
work on a resource that uses this feature, or to add it to an existing one!
|
work on a resource that uses this feature, or to add it to an existing one!
|
||||||
|
|
||||||
|
|
||||||
##Send/Recv
|
## Send/Recv
|
||||||
In `mgmt` there is a novel concept called _Send/Recv_. For some background,
|
In `mgmt` there is a novel concept called _Send/Recv_. For some background,
|
||||||
please [read the introductory article](https://ttboj.wordpress.com/2016/12/07/sendrecv-in-mgmt/).
|
please [read the introductory article](https://ttboj.wordpress.com/2016/12/07/sendrecv-in-mgmt/).
|
||||||
When using this feature, the engine will automatically send the user specified
|
When using this feature, the engine will automatically send the user specified
|
||||||
@@ -559,7 +559,7 @@ such as for cache invalidation.
|
|||||||
|
|
||||||
Remember, `Send/Recv` only changes your resource code if you cache state.
|
Remember, `Send/Recv` only changes your resource code if you cache state.
|
||||||
|
|
||||||
##Composite resources
|
## Composite resources
|
||||||
Composite resources are resources which embed one or more existing resources.
|
Composite resources are resources which embed one or more existing resources.
|
||||||
This is useful to prevent code duplication in higher level resource scenarios.
|
This is useful to prevent code duplication in higher level resource scenarios.
|
||||||
The best example of this technique can be seen in the `nspawn` resource which
|
The best example of this technique can be seen in the `nspawn` resource which
|
||||||
@@ -568,30 +568,30 @@ Unfortunately no further documentation about this subject has been written. To
|
|||||||
expand this section, please send a patch! Please contact us if you'd like to
|
expand this section, please send a patch! Please contact us if you'd like to
|
||||||
work on a resource that uses this feature, or to add it to an existing one!
|
work on a resource that uses this feature, or to add it to an existing one!
|
||||||
|
|
||||||
##Frequently asked questions
|
## Frequently asked questions
|
||||||
(Send your questions as a patch to this FAQ! I'll review it, merge it, and
|
(Send your questions as a patch to this FAQ! I'll review it, merge it, and
|
||||||
respond by commit with the answer.)
|
respond by commit with the answer.)
|
||||||
|
|
||||||
###Can I write resources in a different language?
|
### Can I write resources in a different language?
|
||||||
Currently `golang` is the only supported language for built-in resources. We
|
Currently `golang` is the only supported language for built-in resources. We
|
||||||
might consider allowing external resources to be imported in the future. This
|
might consider allowing external resources to be imported in the future. This
|
||||||
will likely require a language that can expose a C-like API, such as `python` or
|
will likely require a language that can expose a C-like API, such as `python` or
|
||||||
`ruby`. Custom `golang` resources are already possible when using mgmt as a lib.
|
`ruby`. Custom `golang` resources are already possible when using mgmt as a lib.
|
||||||
Higher level resource collections will be possible once the `mgmt` DSL is ready.
|
Higher level resource collections will be possible once the `mgmt` DSL is ready.
|
||||||
|
|
||||||
###What new resource primitives need writing?
|
### What new resource primitives need writing?
|
||||||
There are still many ideas for new resources that haven't been written yet. If
|
There are still many ideas for new resources that haven't been written yet. If
|
||||||
you'd like to contribute one, please contact us and tell us about your idea!
|
you'd like to contribute one, please contact us and tell us about your idea!
|
||||||
|
|
||||||
###Where can I find more information about mgmt?
|
### Where can I find more information about mgmt?
|
||||||
Additional blog posts, videos and other material [is available!](https://github.com/purpleidea/mgmt/#on-the-web).
|
Additional blog posts, videos and other material [is available!](https://github.com/purpleidea/mgmt/#on-the-web).
|
||||||
|
|
||||||
##Suggestions
|
## Suggestions
|
||||||
If you have any ideas for API changes or other improvements to resource writing,
|
If you have any ideas for API changes or other improvements to resource writing,
|
||||||
please let us know! We're still pre 1.0 and pre 0.1 and happy to break API in
|
please let us know! We're still pre 1.0 and pre 0.1 and happy to break API in
|
||||||
order to get it right!
|
order to get it right!
|
||||||
|
|
||||||
##Authors
|
## Authors
|
||||||
|
|
||||||
Copyright (C) 2013-2016+ James Shubin and the project contributors
|
Copyright (C) 2013-2016+ James Shubin and the project contributors
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user