| 1 | <!doctype html> |
| 2 | |
| 3 | <title>CodeMirror: Puppet mode</title> |
| 4 | <meta charset="utf-8"/> |
| 5 | <link rel=stylesheet href="../../doc/docs.css"> |
| 6 | |
| 7 | <link rel="stylesheet" href="../../lib/codemirror.css"> |
| 8 | <script src="../../lib/codemirror.js"></script> |
| 9 | <script src="../../addon/edit/matchbrackets.js"></script> |
| 10 | <script src="puppet.js"></script> |
| 11 | <style> |
| 12 | .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;} |
| 13 | .cm-s-default span.cm-arrow { color: red; } |
| 14 | </style> |
| 15 | <div id=nav> |
| 16 | <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a> |
| 17 | |
| 18 | <ul> |
| 19 | <li><a href="../../index.html">Home</a> |
| 20 | <li><a href="../../doc/manual.html">Manual</a> |
| 21 | <li><a href="https://github.com/codemirror/codemirror">Code</a> |
| 22 | </ul> |
| 23 | <ul> |
| 24 | <li><a href="../index.html">Language modes</a> |
| 25 | <li><a class=active href="#">Puppet</a> |
| 26 | </ul> |
| 27 | </div> |
| 28 | |
| 29 | <article> |
| 30 | <h2>Puppet mode</h2> |
| 31 | <form><textarea id="code" name="code"> |
| 32 | # == Class: automysqlbackup |
| 33 | # |
| 34 | # Puppet module to install AutoMySQLBackup for periodic MySQL backups. |
| 35 | # |
| 36 | # class { 'automysqlbackup': |
| 37 | # backup_dir => '/mnt/backups', |
| 38 | # } |
| 39 | # |
| 40 | |
| 41 | class automysqlbackup ( |
| 42 | $bin_dir = $automysqlbackup::params::bin_dir, |
| 43 | $etc_dir = $automysqlbackup::params::etc_dir, |
| 44 | $backup_dir = $automysqlbackup::params::backup_dir, |
| 45 | $install_multicore = undef, |
| 46 | $config = {}, |
| 47 | $config_defaults = {}, |
| 48 | ) inherits automysqlbackup::params { |
| 49 | |
| 50 | # Ensure valid paths are assigned |
| 51 | validate_absolute_path($bin_dir) |
| 52 | validate_absolute_path($etc_dir) |
| 53 | validate_absolute_path($backup_dir) |
| 54 | |
| 55 | # Create a subdirectory in /etc for config files |
| 56 | file { $etc_dir: |
| 57 | ensure => directory, |
| 58 | owner => 'root', |
| 59 | group => 'root', |
| 60 | mode => '0750', |
| 61 | } |
| 62 | |
| 63 | # Create an example backup file, useful for reference |
| 64 | file { "${etc_dir}/automysqlbackup.conf.example": |
| 65 | ensure => file, |
| 66 | owner => 'root', |
| 67 | group => 'root', |
| 68 | mode => '0660', |
| 69 | source => 'puppet:///modules/automysqlbackup/automysqlbackup.conf', |
| 70 | } |
| 71 | |
| 72 | # Add files from the developer |
| 73 | file { "${etc_dir}/AMB_README": |
| 74 | ensure => file, |
| 75 | source => 'puppet:///modules/automysqlbackup/AMB_README', |
| 76 | } |
| 77 | file { "${etc_dir}/AMB_LICENSE": |
| 78 | ensure => file, |
| 79 | source => 'puppet:///modules/automysqlbackup/AMB_LICENSE', |
| 80 | } |
| 81 | |
| 82 | # Install the actual binary file |
| 83 | file { "${bin_dir}/automysqlbackup": |
| 84 | ensure => file, |
| 85 | owner => 'root', |
| 86 | group => 'root', |
| 87 | mode => '0755', |
| 88 | source => 'puppet:///modules/automysqlbackup/automysqlbackup', |
| 89 | } |
| 90 | |
| 91 | # Create the base backup directory |
| 92 | file { $backup_dir: |
| 93 | ensure => directory, |
| 94 | owner => 'root', |
| 95 | group => 'root', |
| 96 | mode => '0755', |
| 97 | } |
| 98 | |
| 99 | # If you'd like to keep your config in hiera and pass it to this class |
| 100 | if !empty($config) { |
| 101 | create_resources('automysqlbackup::backup', $config, $config_defaults) |
| 102 | } |
| 103 | |
| 104 | # If using RedHat family, must have the RPMforge repo's enabled |
| 105 | if $install_multicore { |
| 106 | package { ['pigz', 'pbzip2']: ensure => installed } |
| 107 | } |
| 108 | |
| 109 | } |
| 110 | </textarea></form> |
| 111 | <script> |
| 112 | var editor = CodeMirror.fromTextArea(document.getElementById("code"), { |
| 113 | mode: "text/x-puppet", |
| 114 | matchBrackets: true, |
| 115 | indentUnit: 4 |
| 116 | }); |
| 117 | </script> |
| 118 | |
| 119 | <p><strong>MIME types defined:</strong> <code>text/x-puppet</code>.</p> |
| 120 | |
| 121 | </article> |