ajout liens edition

main
zen 2024-04-26 13:27:32 +02:00
parent 69488086da
commit b5c594aac0
11 changed files with 72 additions and 40 deletions

View File

@ -9,12 +9,13 @@ services:
- "traefik.docker.network=traefik"
- "traefik.http.routers.autoinstall.entrypoints=websecure"
- "traefik.http.routers.autoinstall.tls=true"
- "traefik.http.routers.autoinstall.rule=Host(`zenisntall.install.lan`)"
- "traefik.http.routers.autoinstall.rule=Host(`zeninstall.zen6.info`)"
- "traefik.http.services.autoinstall.loadbalancer.server.port=3000"
- "traefik.http.routers.autoinstall.tls.certresolver=le"
stdin_open: true
tty: true
ports:
- 4000:3000
# ports:
# - 4000:3000
networks:
- traefik

View File

@ -21,6 +21,7 @@ class EngineController < ApplicationController
if @host.toinstall
@host.update({status: "Computer Booting"})
end
@api_uri = get_uri(@site)
result = render inline: boot_script, layout: false, content_type: 'text/plain'
@host.update({lastbootgenerated: result})
end
@ -37,6 +38,7 @@ class EngineController < ApplicationController
@template = @host.installtemplate
host = @host
@host.update({status: "System Install"})
@api_uri = get_uri(@site)
result = render inline: script, layout: false, content_type: 'text/plain'
@host.update({lastinstallgenerated: result})
else
@ -57,6 +59,7 @@ class EngineController < ApplicationController
@site = @host.site
host = @host
@template = @host.installtemplate
@api_uri = get_uri(@site)
result = render inline: script, layout: false, content_type: 'text/plain'
@host.update({lastpostinstallgenerated: result})
end
@ -100,6 +103,7 @@ class EngineController < ApplicationController
@site = @host.site
@template = @host.installtemplate
host = @host
@api_uri = get_uri(@site)
result = render inline: script.content, layout: false, content_type: 'text/plain'
end
end
@ -118,13 +122,19 @@ class EngineController < ApplicationController
# Generate random lusk key
random_string=SecureRandom.urlsafe_base64(24)
# Create new host
@host = Host.new(hostname: "New host detected",uuid: params["uuid"], install_ip: params["ip"], installtemplate: @template,site: @site, mac: params["mac"], status: "discover", discover: true,installed: false, toinstall: false,rootaccount: @account, mainaccount: @account, product: params["product"], serial: params["serial"], lusk_key: random_string)
@host = Host.new(hostname: "New host detected",uuid: params["uuid"], install_ip: params["ip"], installtemplate: @template,site: @site, mac: params["mac"], status: "discover", discover: true,installed: false, toinstall: false,rootaccount: @account, mainaccount: @account, product: params["p"], serial: params["s"], lusk_key: random_string)
@host.save!
end
end
# Only allow a list of trusted parameters through.
def host_params
params.require(:host).permit(:uuid, :hostname, :ip, :status, :mac, :discover, :installed, :interface , :installtemplate, :site , :installtemplate_id, :site_id, :rootaccount_id, :mainaccount_id,:toinstall, :install_ip, :filename, :access_ip, :product, :serial)
params.require(:host).permit(:uuid, :hostname, :ip, :status, :mac, :discover, :installed, :interface , :installtemplate, :site , :installtemplate_id, :site_id, :rootaccount_id, :mainaccount_id,:toinstall, :install_ip, :filename, :access_ip, :product, :serial,:p,:s)
end
end
def get_uri(site)
if site.api_url.empty?
return "http://#{site.api_ip}:#{site.api_port}"
else
return site.api_url
end
end

View File

@ -72,6 +72,7 @@ class HostsController < ApplicationController
@site = @host.site
host = @host
@template = @host.installtemplate
@api_uri = get_uri(@site)
result = render inline: boot_script, layout: false, content_type: 'text/plain'
@host.update({lastbootgenerated: result})
@ -85,6 +86,7 @@ class HostsController < ApplicationController
@site = @host.site
host = @host
@template = @host.installtemplate
@api_uri = get_uri(@site)
result = render inline: script, layout: false, content_type: 'text/plain'
@host.update({lastinstallgenerated: result})
end
@ -97,6 +99,7 @@ class HostsController < ApplicationController
@ansible = Account.find_by(name: "ansible")
@site = @host.site
host = @host
@api_uri = get_uri(@site)
@template = @host.installtemplate
result = render inline: script, layout: false, content_type: 'text/plain'
end
@ -112,6 +115,14 @@ class HostsController < ApplicationController
private
# Use callbacks to share common setup or constraints between actions.
def get_uri(site)
if site.api_url.empty?
return "http://#{site.api_ip}:#{site.api_port}"
else
return site.api_url
end
end
def set_host
logger.debug "#{params}"
@host = Host.find(params[:id])

View File

@ -66,7 +66,7 @@ class SitesController < ApplicationController
# Only allow a list of trusted parameters through.
def site_params
params.require(:site).permit(:name, :domain, :gateway, :nameserver, :network, :netmask, :server_ip, :server_port, :fileserver_ip, :fileserver_port,:fileserver_basepath, :timezone, :apiurl, :cfenginehub, :nfsserver_path, :country)
params.require(:site).permit(:name, :domain, :gateway, :nameserver, :network, :netmask, :api_ip, :api_port, :api_url, :fileserver_uri, :fileserver_basepath, :timezone, :apiurl, :cfenginehub, :nfsserver_path, :country)
end

View File

@ -7,17 +7,19 @@ class Site
field :nameserver, type: String
field :network, type: String
field :netmask, type: String
field :server_ip, type: String
field :server_port, type: String
field :fileserver_ip, type: String
field :fileserver_port, type: String
field :api_ip, type: String
field :api_port, type: String
field :api_url, type: String
field :fileserver_uri, type: String
field :fileserver_basepath, type: String
field :fileserver_url, type: String
field :nfsserver_ip, type: String
field :nfsserver_path, type: String
field :country, type: String
field :timezone, type: String
field :apiurl, type: String
field :description, type: String
field :cfenginehub, type: String
field :cfenginehub, type: String , default: ''
has_many :sitereferences, class_name: "Host", inverse_of: :site
end

View File

@ -238,3 +238,5 @@
</div>
</div>
</div>
<%= button_to "Edit Template", "/installtemplates/#{@host.installtemplate_id}/edit", method: :get, class: "button is-small is-primary", form: {target: '_blank'}%></tr>

View File

@ -56,7 +56,7 @@
<%= form.text_field :kernel , { class: "input"} %>
</div>
</div>
<div class="field">
<%= form.label :initrd, class: "label" %>
<div class="control">
@ -95,17 +95,24 @@
</div>
</div>
<div class="field">
<%= form.label :lang, class: "label" %>
<div class="control">
<%= form.text_field :lang , { class: "input"} %>
</div>
</div>
<div class="control">
<button class="button is-link">Submit</button>
<button class="button is-link">Submit</button>
<%= link_to "Return", "/installtemplates", class: "button is-success" %>
</div>
<% end %>
<section class="section">
<div class="columns">
<%= button_to "Edit Boot", "/scripts/#{@installtemplate.boot_id}/edit", method: :get, class: "button is-small is-primary" , form: {target: '_blank'}%>
<%= button_to "Edit Install", "/scripts/#{@installtemplate.install_id}/edit", method: :get, class: "button is-small is-primary", form: {target: '_blank'} %>
<%= button_to "Edit Post Install", "/scripts/#{@installtemplate.postinstall_id}/edit", method: :get, class: "button is-small is-primary", form: {target: '_blank'} %>
</div>
</section>

View File

@ -43,9 +43,9 @@
</div>
<div class="field">
<%= form.label :apiurl, class: "label" %>
<%= form.label :api_url, class: "label" %>
<div class="control">
<%= form.text_field :apiurl , { class: "input"} %>
<%= form.text_field :api_url , { class: "input"} %>
</div>
</div>
@ -59,37 +59,37 @@
<div class="field is-grouped">
<div class="field">
<label class="label">Serveur IP</label>
<label class="label">api_ip</label>
<div class="control">
<%= form.text_field :server_ip , { class: "input"} %>
<%= form.text_field :api_ip , { class: "input"} %>
</div>
</div>
<div class="field">
<label class="label">Serveur Port</label>
<label class="label">api_port</label>
<div class="control">
<%= form.text_field :server_port , { class: "input"} %>
<%= form.text_field :api_port , { class: "input"} %>
</div>
</div>
<div class="field">
<label class="label">api_url</label>
<div class="control">
<%= form.text_field :api_url , { class: "input"} %>
</div>
</div>
</div>
<div class="field is-grouped">
<div class="field">
<label class="label">File Server Ip</label>
<label class="label">fileserver_uri</label>
<div class="control">
<%= form.text_field :fileserver_ip , { class: "input"} %>
<%= form.text_field :fileserver_uri , { class: "input"} %>
</div>
</div>
<div class="field">
<label class="label">File Server Port</label>
<div class="control">
<%= form.text_field :fileserver_port , { class: "input"} %>
</div>
</div>
<div class="field">
<label class="label">File Server Basepath</label>
<label class="label">fileserver_basepath</label>
<div class="control">
<%= form.text_field :fileserver_basepath , { class: "input"} %>
</div>
@ -102,9 +102,8 @@
<%= form.text_field :cfenginehub , { class: "input"} %>
</div>
</div>
<% if not @site.cfenginehub.empty? -%>
<%= link_to "Goto cfengine hub", "http://#{@site.cfenginehub}", class: "button is-info", :target => "_blank" %>
<% end -%>
<%= link_to "Goto cfengine hub", "http://#{@site.cfenginehub}", class: "button is-info", :target => "_blank" %>
<div class="field">
<%= form.label :country, class: "label" %>

View File

@ -31,7 +31,7 @@
<p>
<strong>Server:</strong>
<%= site.server_ip %>:<%= site.server_port %>:
<%= site.api_ip %>:<%= site.api_ip %>:
</p>
</div>

View File

@ -35,6 +35,6 @@ module Autogen
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
config.hosts << "zeninstall.install.lan"
config.hosts << "zeninstall.zen6.info"
end
end

View File

@ -4,7 +4,7 @@ development:
# Defines the default client. (required)
default:
# Mongoid can connect to a URI accepted by the driver:
uri: mongodb://railszen:railszen@mongo:27017/railszen
uri: mongodb://zeninstall:pTcwn5FSHWQaedVhxzLZ8g@mongo:27017/railszen
# Otherwise define the parameters separately.
# This defines the name of the default database that Mongoid can connect to.
# (required).
@ -175,11 +175,11 @@ development:
test:
clients:
default:
uri: mongodb://railszen:railszen@mongo:27017/railszen
uri: mongodb://zeninstall:pTcwn5FSHWQaedVhxzLZ8g @mongo:27017/railszen
# database: autodeploy_test
# hosts:
# - localhost:27017
options:
read:
mode: :primary
max_pool_size: 1
max_pool_size: 1