logo
down
shadow

Puppet: file_line evaluates os.path.join


Puppet: file_line evaluates os.path.join

By : Brianna Boswell
Date : October 15 2020, 08:10 AM
may help you . You need to bear in mind that the match parameter to a file_line resource conveys a regular expression, not a plain string. Puppet uses the Ruby flavor of regular expressions. In that dialect, like in many others, the parentheses (()) are metacharacters, signifying grouping. You must escape them if you want them to be interpreted as literals. Moreover, because Ruby regexes use the same escape character that Puppet strings do, you must also escape the escape character to pass it through Puppet to the underlying regex engine. On the other hand, you do not need to escape single quotes inside a double-quoted string, or vise versa, though doing so should not be harmful.
Example:
code :
file_line { 'replace db name':
  path                => '/var/www/mysite/mysite/settings.py',
  replace             => true,
  line                => "'NAME': os.path.join(BASE_DIR , 'db.mysql'),",
  match               => "'NAME': os.path.join\\(BASE_DIR , 'db.sqlite3'\\),",
  append_on_no_match  => false,
}
file_line { 'replace db name':
  path                => '/var/www/mysite/mysite/settings.py',
  replace             => true,
  line                => 'Whatever the line should really be',
  match               => "\\s*'NAME':.*",
  append_on_no_match  => false,
}


Share : facebook icon twitter icon
cannot run command from puppet to update servers for puppet agent using puppet enterprise

cannot run command from puppet to update servers for puppet agent using puppet enterprise


By : 박준우
Date : March 29 2020, 07:55 AM
may help you . Either run puppet agent as root (which as far as I know is a common practice) or add suid on yum to allow others to run it as root (risky!) or run "sudo yum update -y" and add your puppet agent user to sudoers without password prompt.
Correct way to regex match parenthesis in puppet file_line after clause

Correct way to regex match parenthesis in puppet file_line after clause


By : HollyCory Day
Date : March 29 2020, 07:55 AM
this one helps. Yes, you do need to escape the parantheses insides of your regular expression within the after attribute of your file_line resource. Parantheses are used within regular expressions to capture parts of the expression for use by variables later. However, the warnings are arising because you have double quotes (") for your regexp string. This is causing the Puppet parser to initially interpret the \ as interpolated string escapes and not regexp escapes. Therefore, you need to change your regexp value to a literal string for the parser to interpret it correctly.
code :
after   => '^\s+\(ADDRESS = \(PROTOCOL = TCPS\)\(HOST =  DB\)\(PORT = 1522\)\)',
Puppet file_line in specific order

Puppet file_line in specific order


By : 79r5y3
Date : March 29 2020, 07:55 AM
I wish did fix the issue. TL;DR
You basically have three options: try to create ordered dependencies (which is not really the Puppet way), create compound statements, or use /etc/profile.d if your distribution supports it. While there is no single "best" way to handle this, a compound statement or declaration is probably the simplest solution for you.
code :
file_line { 'set TMOUT':
  ensure => present,
  path   => '/etc/profile',
  line   => 'TMOUT=43200',
  match  => '^TMOUT',
} ->
file_line { 'export TMOUT':
  ensure => present,
  path   => '/etc/profile',
  line   => 'export TMOUT',
  after  => '^TMOUT=',
} ->
file_line { 'set TMOUT as readonly':
  ensure => present,
  path   => '/etc/profile',
  line   => 'readonly TMOUT',
  after  => '^export TMOUT',
}
file_line { 'profile TMOUT':
  ensure => present,
  path   => '/etc/profile',
  line   => 'TMOUT=43200; export TMOUT; readonly TMOUT',
  match  => '^TMOUT',
}
file_line { 'profile TMOUT':
  ensure => present,
  path   => '/etc/profile',
  line   => 'declare -r -x TMOUT=43200',
  match  => '^TMOUT',
}
# Create your snippet in the /etc/profile.d directory.
file {'/etc/profile.d/tmout.sh':
  ensure => present,
  content => "TMOUT=43200\nexport TMOUT\nreadonly TMOUT",
} ->

# Remove the lines in /etc/profile if they exist.
file_line { 'profile TMOUT':
  ensure            => absent,
  path              => '/etc/profile',
  match             => 'TMOUT',
  match_for_absence => true,
  multiple          => true,
}
Puppet file_line only if file exists

Puppet file_line only if file exists


By : user2715698
Date : March 29 2020, 07:55 AM
should help you out You probably1 need to create a custom fact that reports on the existence of this file.
code :
# has_java_security.rb

Facter.add(:has_java_security) do
  setcode do
    File.exist?('/etc/alternatives/jre/lib/security/java.security')
  end
end
if $facts['has_java_security'] {
  file_line {'java_security_random':
    line  => 'securerandom.source=file:/dev/urandom',
    path  => '/etc/alternatives/jre/lib/security/java.security',
    match => /^securerandom.source=.*/,
  }
}
Puppet : how to resolve "file_line" multi match patterns

Puppet : how to resolve "file_line" multi match patterns


By : Marián Bednárik
Date : March 29 2020, 07:55 AM
around this issue The after attribute will solve this problem for you. Taking your second resource and cleaning up some, we have:
Related Posts Related Posts :
  • How to setup local server for wordpress site with git
  • Multiplying CASE row with different values
  • Index on a table not being used all the time
  • How can I get a date from mysql database if it is not null?
  • How to execute a TRIGGER in MSSQl?
  • MySQL 8 Window Functions + Full-text searching
  • Join on large table getting slower
  • Select record from two different table
  • Getting 1064 error while creating mysql trigger
  • MySQL Database Operations
  • How can I make this SQL sort by most relevent?
  • Database query on month
  • Select number of matching rows of a particular column in MySQL
  • How to use rake database commands with password
  • If we change a primary key value, why don't we have to change a dependent column value?
  • MySQL - selecting all records except the ones already associated in the relational table
  • Delete Duplicate MySQL rows but keep one
  • ORDER BY does not perform any function
  • Update column with output of select within the same table in mysql
  • Set a variable inside case statement in mysql
  • MYSQL: How to get rows inserted in the last X hours without querying the entire table
  • AWS RDS MySQL Cross-region replication
  • Cannot truncate a table referenced in a foreign key constraint from empty table
  • How does SQL determine a character's length in a varchar?
  • MySQL : Getting DB row with exact same data from a vector
  • Mysql update query with join
  • Group values that have the same name in one column and same id in other column
  • Mysql query syntax for conditional inserts
  • Is it faster to run an SQL count(*) query in a loop, or try to merge it into the parent query?
  • MySQL query to fetch product variants
  • Report Reindex taking too long after destroy
  • MySQL - Adding varchar as a foreign key
  • How to find duplicated entries which has different slug?
  • SQL Query comparing values in different rows
  • Eloquent giving error but query executes fine in phpmyadmin
  • JPQL fetch data from multiple tables
  • MySql Query - Expanding data into new table
  • Official MySQL Docker container not caching queries?
  • MySQL, Count values in every fields in a table
  • SQL : number different dates within users
  • elastic beanstalk docker app cannot connect to mysql
  • Why am I getting errno: 150 "Foreign key constraint is incorrectly formed"?
  • Update columns which included in payload
  • MySQL subquery in select
  • Get difference in top 2 salary of employee from each department
  • connecting to database using RMySQL and .my.cnf file in R
  • How to get data by mysql
  • SQL Error [1054] [42S22]: Unknown column ' ' in 'field list'
  • turn c# code into mysql function
  • How to loop through and output nested array in Laravel
  • MySQL TRIM spaces inside text
  • Mysql query with multiple selects results in high CPU load
  • Backup DB Django MysqlDump
  • How to select all rows from group, until occurrence of a value
  • Using substring to filter a specific word from a string in MySQL
  • Mysql - Alias in Left Outer Join giving error
  • How use custom alias field from select fields in join?
  • How to sum durations in units of Year, Month and Day in MySQL?
  • Is it possible to assign the values from select exist query in MySQL to multiple variables in a stored procedure?
  • How does mysql resolves conflict when same option is configured twice?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org