Class: Ansible::Ruby::Modules::Replace
- Inherits:
-
Base
- Object
- Ansible::Ruby::Models::Base
- Base
- Ansible::Ruby::Modules::Replace
- Includes:
- Helpers::FileAttributes
- Defined in:
- lib/ansible/ruby/modules/generated/files/replace.rb,
lib/ansible/ruby/modules/custom/files/replace.rb
Overview
This module will replace all instances of a pattern within a file. It is up to the user to maintain idempotence by ensuring that the same pattern would never match any replacements made.
Instance Method Summary collapse
-
#after ⇒ String?
If specified, the line after the replace/remove will start.
-
#backup ⇒ :yes, ...
Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly.
-
#before ⇒ String?
If specified, the line before the replace/remove will occur.
-
#encoding ⇒ String?
The character encoding for reading and writing the file.
-
#others ⇒ Object?
All arguments accepted by the M(file) module also work here.
-
#path ⇒ String
The file to modify.,Before 2.3 this option was only usable as I(dest), I(destfile) and I(name).
-
#regexp ⇒ String
The regular expression to look for in the contents of the file.
-
#replace ⇒ String?
The string to replace regexp matches.
Methods included from Helpers::FileAttributes
Methods inherited from Base
Methods inherited from Ansible::Ruby::Models::Base
attr_option, attr_options, attribute, fix_inclusion, #initialize, remove_existing_validations, #to_h, validates
Constructor Details
This class inherits a constructor from Ansible::Ruby::Models::Base
Instance Method Details
#after ⇒ String?
Returns If specified, the line after the replace/remove will start. Can be used in combination with C(before). Uses Python regular expressions; see U(docs.python.org/2/library/re.html).
25 |
# File 'lib/ansible/ruby/modules/generated/files/replace.rb', line 25 attribute :after |
#backup ⇒ :yes, ...
Returns Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly.
33 |
# File 'lib/ansible/ruby/modules/generated/files/replace.rb', line 33 attribute :backup |
#before ⇒ String?
Returns If specified, the line before the replace/remove will occur. Can be used in combination with C(after). Uses Python regular expressions; see U(docs.python.org/2/library/re.html).
29 |
# File 'lib/ansible/ruby/modules/generated/files/replace.rb', line 29 attribute :before |
#encoding ⇒ String?
Returns The character encoding for reading and writing the file.
40 |
# File 'lib/ansible/ruby/modules/generated/files/replace.rb', line 40 attribute :encoding |
#others ⇒ Object?
Returns All arguments accepted by the M(file) module also work here.
37 |
# File 'lib/ansible/ruby/modules/generated/files/replace.rb', line 37 attribute :others |
#path ⇒ String
Returns The file to modify.,Before 2.3 this option was only usable as I(dest), I(destfile) and I(name).
13 |
# File 'lib/ansible/ruby/modules/generated/files/replace.rb', line 13 attribute :path |
#regexp ⇒ String
Returns The regular expression to look for in the contents of the file. Uses Python regular expressions; see U(docs.python.org/2/library/re.html). Uses MULTILINE mode, which means C(^) and C($) match the beginning and end of the file, as well as the beginning and end respectively of I(each line) of the file.,Does not use DOTALL, which means the C(.) special character matches any character I(except newlines). A common mistake is to assume that a negated character set like C() will also not match newlines. In order to exclude newlines, they must be added to the set like C().,Note that, as of ansible 2, short form tasks should have any escape sequences backslash-escaped in order to prevent them being parsed as string literal escapes. See the examples.
17 |
# File 'lib/ansible/ruby/modules/generated/files/replace.rb', line 17 attribute :regexp |
#replace ⇒ String?
Returns The string to replace regexp matches. May contain backreferences that will get expanded with the regexp capture groups if the regexp matches. If not set, matches are removed entirely.
21 |
# File 'lib/ansible/ruby/modules/generated/files/replace.rb', line 21 attribute :replace |