A module for extracting values (via regexp pattern) from an existing file on remote nodes. Should fail silently by default (or loudly if desired), when said file doesn't exist.
I have a group of servers using keepalived to ping each other and elect a master for the group. They find each other via a list of peer ip addresses, and hold election based on differing numeric priorities.
The peer lists and priorities are empty/zeroed for newly provisioned servers, and a separate tool calculates and overwrites them after provisioning.
Should I re-provision an existing server, I need to carry over those specific config values to the regenerated config file, rather than emptying/zeroing them again.
I've been accomplishing this with a custom python script that is (1) copied to the remote node, (2) made executable, (3) run, and (4) its output registered to a variable. I then use the registered variable in a conditional of the config file template.
Said custom script literally just slurps the file and prints any groups returned from re.search.
I've simplified it with the module in question, so my playbook went from this:
- copy: >
- command: /tmp/unicast-peers.py
- command: rm -f /tmp/unicast-peers.py
- debug: var=keepalive_peers.stdout
- blockfromfile: >
- debug: var=keepalive_peers.matches.0.named_groups.peers
add blockfromfile module, to retrieve regexp matches from remote file
Thanks for submitting this new module.
To help facilitate reviews, we’ve broadened the number of people who can approve modules for inclusion into the Extras repository. The list of official reviewers can be found here:
Our new policy is that if a new module is reviewed and approved by at least two official module reviewers, and receives no -1 votes, the module will be approved for inclusion. We will be asking the community of reviewers to take a look at these modules on a regular basis.
To ensure that your module has the best chance of being approved, please double-check that you adhere to the Ansible module guidelines: http://docs.ansible.com/developing_modules.html#module-checklist
Fixed exit message for no matches
Wrapped file open for exceptions
Try..except should use 2.4 var syntax; changed rc for file open excep…
Hi -- updating this PR with the new modules reviewer guidelines, which will hopefully help move this module along to get reviews for inclusion.
Thanks for submitting this new module to Ansible Extras! This module is now in community review, a process that is open to all Ansible users. In order for this module to be approved, it must gain the following votes, which can be contributed by anyone other than the author of the new module:
“works_for_me”: If you have tested the module thoroughly, including testing of all of the module’s options, and if the module works for you, please add “works_for_me” in the comments.
“passes_guidelines”: If you have gone through the module guidelines and the module meets all of the requirements, please add “passes_guidelines” in the comments. Guidelines are available here: http://docs.ansible.com/developing_modules.html#module-checklist
“needs_revision”: If the module fails to work for you, or if it doesn’t meet guidelines, please add “needs_revision” in the comments with details about what needs to be fixed.
When a module has both “works_for_me” and “passes_guidelines” tags, we will promote the module for inclusion in Ansible Extras. At this point, you will be expected to maintain the module by fixing bugs and evaluating pull requests in a timely manner.
More information about the review process can be seen here:
Thanks again for submitting your Ansible module!
I have tested this module using the latest devel on Ubuntu 14.04 LTS. I tested:
So this behaved as I would expect.
Thanks @EvanK for this PR. This PR requires revisions, either because it fails to build or by reviewer request. Please make the suggested revisions. When you are done, please comment with text 'ready_for_review' and we will put this PR back into review.
Merge branch 'devel' into module-blockfromfile
Merged latest upstream devel, and added RETURN documentation.
Thanks @EvanK for this new module. When this module receives 'shipit' comments from two community members and any 'needs_revision' comments have been resolved, we will mark for inclusion.
[This message brought to you by your friendly Ansibull-bot.]
This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible
Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.
Added blockfromfile module, to retrieve regexp matches from remote file
Moved from ansible/ansible-modules-extras#962