oxidized
oxidized copied to clipboard
Commit files to git repo
In my extended LinuxGeneric model i do a backup and save it as a .tar file, but when i check the repo seems like it wasnt added to recent commit, maybe i missing something, can someone point it out what is the cause of the problem.
Thanks in advance.
model:
class LinuxGeneric < Oxidized::Model
using Refinements
prompt /^(\w.*|\W.*)(:|#) /
comment '# '
# Global command output processing
cmd :all do |cfg|
cfg.gsub! /^(default (\S+).* (expires) ).*/, '\\1 <redacted>'
cfg.gsub! /\r/, '' # Remove carriage returns
cfg.cut_both
end
# Directories and files to back up
BACKUP_PATHS = [
"/etc/network",
"/etc/fias",
"/etc/dhcp",
"/etc/kea",
"/etc/cfctl",
"/etc/hosts",
"/etc/hostname"
]
cmd "hostname" do |host_output|
device_hostname = host_output.strip
cmd "echo 'Checking directories...'" do |cfg|
comment "Starting backup process for #{device_hostname}"
cfg
end
cmd "for dir in #{BACKUP_PATHS.join(' ')}; do [ -e \"$dir\" ] && echo \"$dir\"; done" do |output|
valid_paths = output.lines.map(&:strip).reject(&:empty?)
if valid_paths.empty?
comment "No valid directories found for backup on #{device_hostname}."
return ""
end
backup_file = "backup.tar"
cmd "tar -cf #{backup_file} #{valid_paths.join(' ')}" do |backup_data|
comment "Backup of existing system configuration files for #{device_hostname}"
backup_data
end
comment "Backup saved to #{backup_file}"
backup_file
end
end
cfg :ssh do
post_login do
if vars(:enable) == true
cmd "sudo su -"
elsif vars(:enable)
cmd "su -", /^Password:/
cmd vars(:enable)
end
end
pre_logout 'exit'
sleep 1
pre_logout 'exit'
end
end
config: ...
output:
default: git
git:
user: ansbl
email: [email protected]
repo: "/home/oxidized/git/git-repos/default.git"
...
This issue is stale because it has been open 90 days with no activity.
Closing Stale Issue.