Class: Rsm::Install::Nginx

Inherits:
Base
  • Object
show all
Defined in:
lib/tasks/install/nginx.rb

Constant Summary

Constants inherited from Base

Base::SERVERS

Constants included from Actions

Actions::TAR_OPTS

Instance Attribute Summary collapse

Attributes inherited from Base

#server, #socket_per_worker, #worker_processes

Instance Method Summary collapse

Methods inherited from Base

#set_server, #set_worker_processes, source_root, template_path

Methods included from Actions

#application_root, #downloaded_file, #fetch_temporary_archive, #ruby_binary, #run_ruby_binary, #run_with_bundler, #unpack_compressed_archive

Instance Attribute Details

#auth_basicObject (readonly)

Returns the value of attribute auth_basic.



4
5
6
# File 'lib/tasks/install/nginx.rb', line 4

def auth_basic
  @auth_basic
end

#auth_basic_realmObject (readonly)

Returns the value of attribute auth_basic_realm.



4
5
6
# File 'lib/tasks/install/nginx.rb', line 4

def auth_basic_realm
  @auth_basic_realm
end

#auth_basic_user_fileObject (readonly)

Returns the value of attribute auth_basic_user_file.



4
5
6
# File 'lib/tasks/install/nginx.rb', line 4

def auth_basic_user_file
  @auth_basic_user_file
end

#domainObject (readonly)

Returns the value of attribute domain.



4
5
6
# File 'lib/tasks/install/nginx.rb', line 4

def domain
  @domain
end

#environmentObject (readonly)

Returns the value of attribute environment.



4
5
6
# File 'lib/tasks/install/nginx.rb', line 4

def environment
  @environment
end

#rewrite_wwwObject (readonly)

Returns the value of attribute rewrite_www.



4
5
6
# File 'lib/tasks/install/nginx.rb', line 4

def rewrite_www
  @rewrite_www
end

#upstream_nameObject (readonly)

Returns the value of attribute upstream_name.



4
5
6
# File 'lib/tasks/install/nginx.rb', line 4

def upstream_name
  @upstream_name
end

Instance Method Details

#enable_nginx_siteObject



45
46
47
# File 'lib/tasks/install/nginx.rb', line 45

def enable_nginx_site
  link_file "#{destination_root}/sites-available.d/#{domain}.conf", "sites-enabled.d/#{domain}.conf" unless FileTest.symlink?("#{destination_root}/sites-enabled.d/#{domain}.conf")
end

#nginx_config_include_vhostsObject



18
19
20
21
22
23
# File 'lib/tasks/install/nginx.rb', line 18

def nginx_config_include_vhosts
  include_str = "include sites-enabled.d/*.conf;"
  unless File.read("#{destination_root}/nginx.conf").include?(include_str)
    inject_into_file "nginx.conf", "#{include_str}\n", :after => "index index.html;\n"
  end
end

#nginx_server_configObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/tasks/install/nginx.rb', line 25

def nginx_server_config
  @environment = options[:environment]
  @domain = options[:domain]
  unless @domain
    @domain = `hostname -f`.strip
    @domain = "#{name}.#{@domain}"
  end

  @rewrite_www = options[:rewrite_www]

  @auth_basic = options[:auth_basic]
  @auth_basic_realm = options[:auth_basic_realm]
  @auth_basic_realm = name.to_s.capitalize unless @auth_basic_realm
  @auth_basic_user_file = options[:auth_basic_user_file]

  @upstream_name = "#{domain}_server"

  template "nginx-server.conf.erb", "sites-available.d/#{domain}.conf"
end

#set_destination_rootObject



14
15
16
# File 'lib/tasks/install/nginx.rb', line 14

def set_destination_root
  self.destination_root = options[:nginx_root]
end