Class: Ansible::Ruby::Modules::Win_lineinfile
- Inherits:
-
Base
- Object
- Ansible::Ruby::Models::Base
- Base
- Ansible::Ruby::Modules::Win_lineinfile
- Defined in:
- lib/ansible/ruby/modules/generated/core/windows/win_lineinfile.rb
Overview
This module will search a file for a line, and ensure that it is present or absent. This is primarily useful when you want to change a single line in a file only.
Instance Method Summary collapse
-
#backrefs ⇒ :yes, ...
Used with C(state=present).
-
#backup ⇒ :yes, ...
Create a backup file including the timestamp information so you can get the original file back if you somehow clobbered it incorrectly.
-
#create ⇒ :yes, ...
Used with C(state=present).
-
#dest ⇒ String
The path of the file to modify.,Note that the Windows path delimiter ‘' must be escaped as ’\‘ (see examples below).
-
#encoding ⇒ String?
Specifies the encoding of the source text file to operate on (and thus what the output encoding will be).
-
#insertafter ⇒ :EOF, ...
Used with C(state=present).
-
#insertbefore ⇒ :BOF, ...
Used with C(state=present).
-
#line ⇒ String?
Required for C(state=present).
-
#newline ⇒ :windows, ...
Specifies the line separator style to use for the modified file.
-
#regexp ⇒ String?
The regular expression to look for in every line of the file.
-
#state ⇒ :present, ...
Whether the line should be there or not.
-
#validate ⇒ Object?
Validation to run before copying into place.
Methods inherited from Base
Methods inherited from Ansible::Ruby::Models::Base
attr_option, attr_options, attribute, #initialize, remove_existing_validations, #to_h, validates
Constructor Details
This class inherits a constructor from Ansible::Ruby::Models::Base
Instance Method Details
#backrefs ⇒ :yes, ...
Returns Used with C(state=present). If set, line can contain backreferences (both positional and named) that will get populated if the C(regexp) matches. This flag changes the operation of the module slightly; C(insertbefore) and C(insertafter) will be ignored, and if the C(regexp) doesn’t match anywhere in the file, the file will be left unchanged.,If the C(regexp) does match, the last matching line will be replaced by the expanded line parameter.
28 |
# File 'lib/ansible/ruby/modules/generated/core/windows/win_lineinfile.rb', line 28 attribute :backrefs |
#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.
44 |
# File 'lib/ansible/ruby/modules/generated/core/windows/win_lineinfile.rb', line 44 attribute :backup |
#create ⇒ :yes, ...
Returns Used with C(state=present). If specified, the file will be created if it does not already exist. By default it will fail if the file is missing.
40 |
# File 'lib/ansible/ruby/modules/generated/core/windows/win_lineinfile.rb', line 40 attribute :create |
#dest ⇒ String
Returns The path of the file to modify.,Note that the Windows path delimiter ‘' must be escaped as ’\‘ (see examples below).
12 |
# File 'lib/ansible/ruby/modules/generated/core/windows/win_lineinfile.rb', line 12 attribute :dest |
#encoding ⇒ String?
Returns Specifies the encoding of the source text file to operate on (and thus what the output encoding will be). The default of C(auto) will cause the module to auto-detect the encoding of the source file and ensure that the modified file is written with the same encoding.,An explicit encoding can be passed as a string that is a valid value to pass to the .NET framework System.Text.Encoding.GetEncoding() method - see U(msdn.microsoft.com/en-us/library/system.text.encoding%28v=vs.110%29.aspx).,This is mostly useful with C(create=yes) if you want to create a new file with a specific encoding. If C(create=yes) is specified without a specific encoding, the default encoding (UTF-8, no BOM) will be used.
51 |
# File 'lib/ansible/ruby/modules/generated/core/windows/win_lineinfile.rb', line 51 attribute :encoding |
#insertafter ⇒ :EOF, ...
Returns Used with C(state=present). If specified, the line will be inserted after the last match of specified regular expression. A special value is available; C(EOF) for inserting the line at the end of the file.,If specified regular expression has no matches, EOF will be used instead. May not be used with C(backrefs).
32 |
# File 'lib/ansible/ruby/modules/generated/core/windows/win_lineinfile.rb', line 32 attribute :insertafter |
#insertbefore ⇒ :BOF, ...
Returns Used with C(state=present). If specified, the line will be inserted before the last match of specified regular expression. A value is available; C(BOF) for inserting the line at the beginning of the file.,If specified regular expression has no matches, the line will be inserted at the end of the file. May not be used with C(backrefs).
36 |
# File 'lib/ansible/ruby/modules/generated/core/windows/win_lineinfile.rb', line 36 attribute :insertbefore |
#line ⇒ String?
Returns Required for C(state=present). The line to insert/replace into the file. If C(backrefs) is set, may contain backreferences that will get expanded with the C(regexp) capture groups if the regexp matches.
24 |
# File 'lib/ansible/ruby/modules/generated/core/windows/win_lineinfile.rb', line 24 attribute :line |
#newline ⇒ :windows, ...
Returns Specifies the line separator style to use for the modified file. This defaults to the windows line separator (rn). Note that the indicated line separator will be used for file output regardless of the original line seperator that appears in the input file.
55 |
# File 'lib/ansible/ruby/modules/generated/core/windows/win_lineinfile.rb', line 55 attribute :newline |
#regexp ⇒ String?
Returns The regular expression to look for in every line of the file. For C(state=present), the pattern to replace if found; only the last line found will be replaced. For C(state=absent), the pattern of the line to remove. Uses .NET compatible regular expressions; see U(msdn.microsoft.com/en-us/library/hs600312%28v=vs.110%29.aspx).
16 |
# File 'lib/ansible/ruby/modules/generated/core/windows/win_lineinfile.rb', line 16 attribute :regexp |
#state ⇒ :present, ...
Returns Whether the line should be there or not.
20 |
# File 'lib/ansible/ruby/modules/generated/core/windows/win_lineinfile.rb', line 20 attribute :state |
#validate ⇒ Object?
Returns Validation to run before copying into place. Use %s in the command to indicate the current file to validate.,The command is passed securely so shell features like expansion and pipes won’t work.
48 |
# File 'lib/ansible/ruby/modules/generated/core/windows/win_lineinfile.rb', line 48 attribute :validate |