LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-11-2013, 08:19 AM   #16
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,627

Rep: Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943

So what happens after you put in the list? (post #13 did not have it in there)
 
Old 11-12-2013, 09:48 AM   #17
sparc86
Member
 
Registered: Jul 2006
Location: Hamburg, Germany
Distribution: Debian, CentOS
Posts: 297

Original Poster
Rep: Reputation: 31
I have tried a different syntax and now it works:

Code:
 ruby_block "insert_line_to_sshd" do
  block do
    file = Chef::Util::FileEdit.new("/etc/hosts")
    file.insert_line_after_match("Authentication:", "AllowUsers/1 user1")
    file.insert_line_after_match("Authentication:", "AllowUsers/1 user2")
    file.write_file
  end
end

HOWEVER, if I run "chef-solo" again, my code will run AGAIN and then keep writing "user1 /n, user2 /n" in the file.

Do you know any Ruby code to work as a conditional in order to avoid these lines to repeat on every "chef-solo" run? Perhaps should I use some kind of regular expression?

Thanks

Last edited by sparc86; 11-14-2013 at 04:07 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find me source code for "iwlist" & "iwconfig" Angela Wu Linux - Kernel 2 09-15-2013 09:44 PM
[SOLVED] "/etc/init.d/apache2" start VS "apache2ctl start" with passenger module (ruby/rails) arond Linux - Server 1 12-13-2010 11:56 AM
[SOLVED] Python "QFileDialog" code not working gary_in_springhill Programming 1 02-03-2010 09:48 AM
net working eth0 eth1 wlan0 "no connection" "no LAN" "no wi-fi" Cayitano Linux - Newbie 5 12-09-2007 08:11 PM
Incorrect PHP code is working, shoud I "fix" it? rblampain Programming 6 04-28-2006 11:33 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration