If you don’t use Code Manager and the default setting for environment caching was changed, tasks you add to an environment might be missing or not load. The task either does not appear in the console in the Task field, or when you run puppet task
in the command line, you get a message that the task is not found.
Version and installation information
PE version: All supported versions
Solution
Puppet Server caches the data it loads from disk for each environment. If you don’t use Code Manager (which clears the cache after each deployment), and the default setting for environment-class-cache-enabled
was changed to false
to improve performance, code in your environment cache might not be up to date. If so, you can fix the issue by clearing the cache.
There are two ways to clear the cache, either by using an API call or by restarting the pe-puppetserver service. Using an API call is preferred because restarting pe-puppetserver impacts services.
To clear the cache using an API endpoint
You can manually clear the cache using an API endpoint request. You can either clear the cache for all environments or for a specific environment. A successful request to the endpoint returns HTTP 204: No Content
.
For all environments:
On the primary server, run the following from the command line,:
$ curl -i --cert $(puppet config print hostcert) --key $(puppet config printhostprivkey) --cacert $(puppet config print localcacert) -X DELETE https://$(hostname -f):8140/puppet-admin-api/v1/environment-cache HTTP/1.1 204 No Content
For a specific environment:
Use the optional parameter environment
to clear the cache for a specific environment. For example, for the test environment, on the primary server, run the following from the command line:
$ curl -i --cert $(puppet config print hostcert) --key $(puppet config printhostprivkey) --cacert $(puppet config print localcacert) -X DELETE https://$(hostname -f):8140/puppet-admin-api/v1/environment-cache?environment=test HTTP/1.1 204 No Content
To clear the cache by restarting pe-puppetserver
On the primary server on the command line, run:
puppet resource service pe-puppetserver ensure=stopped puppet resource service pe-puppetserver ensure=running
How can we improve this article?
0 comments
Please sign in to leave a comment.
Related articles