{"id":15022693,"url":"https://github.com/puppetlabs/puppetlabs-windows_env","last_synced_at":"2025-04-06T14:11:08.169Z","repository":{"id":8757117,"uuid":"10438499","full_name":"puppetlabs/puppetlabs-windows_env","owner":"puppetlabs","description":"Puppet module for managing Windows environment variables. ","archived":false,"fork":false,"pushed_at":"2025-03-27T14:58:07.000Z","size":280,"stargazers_count":14,"open_issues_count":8,"forks_count":23,"subscribers_count":38,"default_branch":"main","last_synced_at":"2025-03-28T05:02:51.853Z","etag":null,"topics":["hacktoberfest","module","puppet","supported","windows-puppet-module"],"latest_commit_sha":null,"homepage":"https://forge.puppet.com/puppet/windows_env","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/puppetlabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-06-02T16:04:29.000Z","updated_at":"2025-03-27T14:57:20.000Z","dependencies_parsed_at":"2024-04-03T09:43:17.276Z","dependency_job_id":"63b6b470-b48d-4ceb-91e2-9cd88350b6e8","html_url":"https://github.com/puppetlabs/puppetlabs-windows_env","commit_stats":{"total_commits":161,"total_committers":24,"mean_commits":6.708333333333333,"dds":0.6335403726708074,"last_synced_commit":"d89f0fb6c58cb6b6024dfe214a283d94c9922582"},"previous_names":["badgerious/puppet-windows-env","voxpupuli/puppet-windows_env"],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puppetlabs%2Fpuppetlabs-windows_env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puppetlabs%2Fpuppetlabs-windows_env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puppetlabs%2Fpuppetlabs-windows_env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/puppetlabs%2Fpuppetlabs-windows_env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/puppetlabs","download_url":"https://codeload.github.com/puppetlabs/puppetlabs-windows_env/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208142,"owners_count":20901570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","module","puppet","supported","windows-puppet-module"],"created_at":"2024-09-24T19:58:16.789Z","updated_at":"2025-04-06T14:11:08.142Z","avatar_url":"https://github.com/puppetlabs.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# windows_env\n\n[![Donated by Vox Pupuli](https://img.shields.io/badge/donated%20by-Vox%20Pupuli-fb7047.svg)](#transfer-notice)\n\n\nThis module manages (system and user) Windows environment variables.\n\n## Installation\n\nInstall from puppet forge:\n\n```sh\npuppet module install puppet/windows_env\n```\n\nInstall from git (do this in your modulepath):\n\n```sh\ngit clone https://github.com/puppetlabs/puppetlabs-windows_env windows_env\n```\n\n## Changes\n\n[CHANGELOG.md](CHANGELOG.md)\n\n## Compatibility\n\nThis module is currently tested against Puppet 4.10 and latest Puppet 5\nreleases. You can see the range of supported Puppet versions in the\n[metadata.json](metadata.json).\n\n## Usage\n\n### Parameters\n\n#### `ensure`\n\nStandard ensure, valid values are `absent` or `present`. Defaults to `present`.\n\n#### `variable` (namevar)\n\nThe name of the environment variable. This will be inferred from the title if\nnot given explicitly. The title can be of either the form `{variable}={value}`\n(the fields will be split on the first `=`) or just `{variable}`.\n\n#### `value` (namevar)\n\nThe value of the environment variable. How this will treat existing content\ndepends on `mergemode`.\n\n#### `user` (namevar)\n\nThe user whose environment will be modified. Default is `undef`, i.e. system\nenvironment. The user can be local or domain, as long as they have a local\nprofile (typically `C:\\users\\{username}` on Vista+). There is no awareness of\nnetwork profiles in this module; knowing how changes to the local profile will\naffect a distributed profile is up to you.\n\n#### `separator`\n\nHow to split entries in environment variables with multiple values (such as\n`PATH` or `PATHEXT`) . Default is `';'`.\n\n#### `mergemode`\n\nSpecifies how to treat content already in the environment variable, and how to\nhandle deletion of variables. Default is `insert`.\n\nValid values:\n\n- `clobber`\n  - When `ensure =\u003e present`, creates a new variable (if necessary) and sets\n    its value. If the variable already exists, its value will be overwritten.\n  - When `ensure =\u003e absent`, the environment variable will be deleted entirely.\n- `insert`\n  - When `ensure =\u003e present`, creates a new variable (if necessary) and sets\n    its value. If the variable already exists, the puppet resource provided\n    content will be merged with the existing content. The puppet provided content\n    will be placed at the end, and separated from existing entries with\n    `separator`. If the specified value is already somewhere in the variable, no\n    change will occur.\n  - When `ensure =\u003e absent`, the value provided by the puppet resource will be\n    removed from the environment variable. Other content will be left\n    unchanged. The environment variable will not be removed, even if its\n    contents are blank.\n- `prepend`\n  - Same as `insert`, except Puppet will ensure the value appears **first**. If\n    the specified value is already in the variable, but not at the beginning, it\n    will be moved to the beginning. In the case of multiple resources in\n    `prepend` mode managing the same variable, the values will be inserted in the\n    order of evaluation (the last to run will be listed first in the variable).\n    Note that with multiple `prepend`s on the same resource, there will be\n    shuffling around on every puppet run, since each resource will place its own\n    value at the front of the list when it is run. Alternatively, an array can be\n    provided to `value`. The relative ordering of the array items will be\n    maintained when they are inserted into the variable, and the shuffling will\n    be avoided.\n- `append`\n  - Same as `prepend`, except the new value will be placed at (or be moved to) the end of the\n    variable's existing contents rather than the beginning.\n\n#### `type`\n\nThe type of registry value to use. Default is `undef` for existing keys (i.e.\ndon't change the type) and `REG_SZ` when creating new keys.\n\nValid values:\n\n- `REG_SZ`\n  - This is a regular registry string item with no substitution.\n- `REG_EXPAND_SZ`\n  - Values of this type will expand '%' enclosed strings (e.g. `%SystemRoot%`)\n    derived from other environment variables. If you're on a 64-bit system and\n    running 32-bit puppet, be careful here; registry writes may be subject to\n    WoW64 registry redirection shenanigans. This module writes keys with the\n    KEY_WOW64_64KEY flag, which on Windows 7+ (Server 2008 R2) systems will\n    disable value rewriting. Older systems will rewrite certain values. The\n    gory details can be found here:\n    http://msdn.microsoft.com/en-us/library/windows/desktop/aa384232%28v=vs.85%29.aspx\n    .\n\n#### `broadcast_timeout`\n\nSpecifies how long (in ms) to wait (per window) for refreshes to go through\nwhen environment variables change. Default is 100ms. This probably doesn't\nneed changing unless you're having issues with the refreshes taking a long time\n(they generally happen nearly instantly). Note that this only works for the user\nthat initiated the puppet run; if puppet runs in the background, updates to the\nenvironment will not propagate to logged in users until they log out and back in\nor refresh their environment by some other means.\n\n### Examples\n\n```puppet\n\n    # Title type #1. Variable name and value are extracted from title, splitting on '='.\n    # Default 'insert' mergemode is selected and default 'present' ensure is selected,\n    # so this will add 'C:\\code\\bin' to PATH, merging it neatly with existing content.\n    windows_env { 'PATH=C:\\code\\bin': }\n\n    # Title type #2. Variable name is derived from the title, but not value (because there is no '=').\n    # This will remove the environment variable 'BADVAR' completely.\n    windows_env { 'BADVAR':\n      ensure    =\u003e absent,\n      mergemode =\u003e clobber,\n    }\n\n    # Title type #3. Title doesn't set parameters (because both 'variable' and 'value' have\n    # been supplied manually).\n    # This will create a new environment variable 'MyVariable' and set its value to 'stuff'.\n    # If the variable already exists, its value will be replaced with 'stuff'.\n    windows_env {'random_title':\n      ensure    =\u003e present,\n      variable  =\u003e 'MyVariable',\n      value     =\u003e 'stuff',\n      mergemode =\u003e clobber,\n    }\n\n    # Variables with type =\u003e 'REG_EXPAND_SZ' allow other environment variables to be used\n    # by enclosing them in percent symbols.\n    windows_env { 'JAVA_HOME=%ProgramFiles%\\Java\\jdk1.6.0_02':\n      type =\u003e 'REG_EXPAND_SZ',\n    }\n\n    # Create an environment variable for 'Administrator':\n    windows_env { 'KOOLVAR':\n      value =\u003e 'hi',\n      user  =\u003e 'Administrator',\n    }\n\n    # Create an environment variable for 'Domain\\FunUser':\n    windows_env { 'Funvar':\n      value =\u003e 'Funval',\n      user  =\u003e 'Domain\\FunUser',\n    }\n\n    # Creates (if needed) an enviroment variable 'VAR', and sticks 'VAL:VAL2' at\n    # the beginning. Separates with : instead of ;. The broadcast_timeout change\n    # probably won't make any difference.\n    windows_env { 'title':\n      ensure            =\u003e present,\n      mergemode         =\u003e prepend,\n      variable          =\u003e 'VAR',\n      value             =\u003e ['VAL', 'VAL2'],\n      separator         =\u003e ':',\n      broadcast_timeout =\u003e 2000,\n    }\n\n    # Exec doStuff.bat whenever environment variable KOOLVAR changes.\n    # Note that if you have multiple windows_env resources managing one\n    # variable, you'll need to either subscribe to all of them or combine\n    # the windows_env resources into one (by passing an array to 'value')\n    # and subscribing to that one resource.\n    exec { 'C:\\doStuff.bat':\n      subscribe   =\u003e Windows_env['KOOLVAR'],\n      refreshonly =\u003e true,\n    }\n```\n\n## Facts\n\n### `windows_env`\n\nA structured fact which lists the following Windows environment variables\n\n- ALLUSERSPROFILE\n- APPDATA\n- COMMONPROGRAMFILES\n- COMMONPROGRAMFILES(X86)\n- HOME\n- HOMEDRIVE\n- HOMEPATH\n- LOCALAPPDATA\n- PATHEXT\n- PROCESSOR_IDENTIFIER\n- PROCESSOR_LEVEL\n- PROCESSOR_REVISION\n- PROGRAMDATA\n- PROGRAMFILES\n- PROGRAMFILES(X86)\n- PSMODULEPATH\n- PUBLIC\n- SYSTEMDRIVE\n- SYSTEMROOT\n- TEMP\n- TMP\n- USERPROFILE\n- WINDIR\n\nNote that the names will appear as uppercase in the fact, for example the `windir` environment variable will appears as `WINDIR` in the fact\n\n### Examples\n\n```puppet\n    $app_data = $facts['windows_env']['APPDATA']\n\n    # Output the AppData path in the puppet log\n    notify { $app_data: }\n```\n\n## Acknowledgements\n\nThe [puppet-windows-path](https://github.com/basti1302/puppet-windows-path)\nmodule by Bastian Krol was the starting point for this module.\npuppetlabs-windows_env got migrated from [badgerious](https;//github.com/badgerious)\nto Vox Pupuli.\n\n## License\n\nThis codebase is licensed under the Apache2.0 licensing, however due to the nature of the codebase the open source dependencies may also use a combination of [AGPL](https://opensource.org/license/agpl-v3/), [BSD-2](https://opensource.org/license/bsd-2-clause/), [BSD-3](https://opensource.org/license/bsd-3-clause/), [GPL2.0](https://opensource.org/license/gpl-2-0/), [LGPL](https://opensource.org/license/lgpl-3-0/), [MIT](https://opensource.org/license/mit/) and [MPL](https://opensource.org/license/mpl-2-0/) Licensing.\n\n## Transfer notice\n\nThis module was previously maintained by Vox Pupuli. It was migrated to Puppet/Perforce in 2023.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuppetlabs%2Fpuppetlabs-windows_env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpuppetlabs%2Fpuppetlabs-windows_env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpuppetlabs%2Fpuppetlabs-windows_env/lists"}