Skip to content

Commit

Permalink
Chef 12 azure rm support (#30)
Browse files Browse the repository at this point in the history
* updating berksfile

* updating metadata

* updating metadata

* updating version

* addin marker

* modifying version in metadata.rb

* adding berksfile

* updating Berksfile to include rs-base, using new Gemfile

* updating travis build info

* adding rakefile

* updating files for cookstyle

* adding base gitignore

* updating so tests will pass

* add .rspec

* updating mysql2 gem

* adding in secrets to fake recipe

* fixing for cookstyle

* uncommenting fake

* adding in curl

* updating to listen from listen_ports

* fixing cookstyle

* updating Berksfile for chef-12-migration

* updating metadata to remove application_php dep lock

* pinning to 2.0.2

* updating ruby-version

* changing from node.set to node.override

* removing server_aliases

* updating server_aliases and kitchen.yml

* updating berksfile and cookstyling default.rb

* trying to add in server_port

* making override variable

* updating for allowoverride

* fixing metadata for allow_override input

* adding loggin

* updating rakefile and berks to remove pin

* updating Berkfile for branch on contrib

* updating to new travis setup

* cleaning up Gemfile

* removing Thorfile, Changelog, Readme, and metadata per peer review

* adding Berksfile.lock

* adding bundle install to setup

* updating to 7.2

* removing rhel

* updating Helper#get_bind_ip_address to use cloud_v2, and node['ipaddress']

* updating Helper#get_bind_ip_address to use cloud_v2, and node['ipaddress'] for public address

* updating for cookstyle

* Use helper to obtain bind IP for loadbalancer backend connectivity

* fixing the database tests

* running cookstyle against libraries/helper.rb

* fixing end alignment

* updating to rightscale_tag -> 2.0.1

* updating mysql_chef_gem error

* fixing cookstyle

* updating to chef-dk 1.2.22

* fixing version number

* updating tests

* fixing tests for centos6, ubuntu12,ubuntu14

* adding mysql files

* fixing cookstyle

* fixing centos-7 test
  • Loading branch information
rshade authored Feb 9, 2017
1 parent ce3075c commit a8890d1
Show file tree
Hide file tree
Showing 29 changed files with 197 additions and 59 deletions.
6 changes: 1 addition & 5 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ suites:
#
- name: database_mysql
run_list:
- recipe[mysql::server]
- recipe[fake::database_mysql]
- recipe[rs-application_php::default]
- recipe[curl::default]
Expand All @@ -101,12 +100,9 @@ suites:
provider: vagrant
public_ips: ['33.33.33.10']
private_ips: ['10.0.2.15']
mysql:
server_root_password: rootpass
server_debian_password: debpass
server_repl_password: replpass
rs-application_php:
application_name: example
write_settings_file: true
scm:
revision: unified_php
repository: git://github.com/rightscale/examples.git
Expand Down
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ language: ruby
rvm:
- 2.3.1
before_install:
- curl -L https://www.getchef.com/chef/install.sh | sudo bash -s -- -P chefdk -v 1.0.3
- gem install bundler -v 1.11.2
- curl -L https://www.getchef.com/chef/install.sh | sudo bash -s -- -P chefdk -v 1.2.22
install:
- chef exec bundle install --jobs=3 --retry=3
before_script: chef exec rake setup_test_environment
Expand Down
1 change: 1 addition & 0 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://supermarket.chef.io'

metadata
Expand Down
15 changes: 9 additions & 6 deletions Berksfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ DEPENDENCIES
revision: 058e70879408fceceb628c600d487b1ddfa06cdb
rightscale_tag
git: https://github.com/rightscale-cookbooks/rightscale_tag.git
revision: d012cd3486fd9fc4efbf5200885bad521301c4b9
revision: 93a8e1d1040f508623fa3cae4fbd7ecf67bcb450
rs-application_php
path: .
metadata: true
rs-base
git: https://github.com/rightscale-cookbooks/rs-base.git
revision: 6dae6b0ce17455210576ca8175f3ad9590547d22
revision: 501761b8977004bee8d38c10b42434c37362d6cb
rsc_remote_recipe
git: https://github.com/rightscale-services-cookbooks/rsc_remote_recipe.git
revision: abff4b0fb96552c71eb5466877b6874274fa380a
Expand Down Expand Up @@ -54,6 +54,9 @@ GRAPH
lvm (~> 3.1)
fake (0.1.0)
database (>= 0.0.0)
mysql (~> 8.2)
mysql2_chef_gem (>= 0.0.0)
yum-mysql-community (>= 0.0.0)
git (5.0.2)
build-essential (>= 0.0.0)
dmg (>= 0.0.0)
Expand Down Expand Up @@ -94,10 +97,10 @@ GRAPH
build-essential (>= 2.0.0)
compat_resource (>= 12.16.3)
openssl (>= 4.0)
rightscale_tag (2.0.0)
rightscale_tag (2.0.1)
machine_tag (~> 2.0)
marker (~> 2.0)
rs-application_php (2.0.0)
rs-application_php (2.0.1)
application (>= 0.0.0)
application_php (~> 2.0.2)
collectd (>= 0.0.0)
Expand All @@ -117,10 +120,10 @@ GRAPH
collectd (~> 2.2.2)
collectd_plugins (~> 2.1.3)
ephemeral_lvm (= 2.0.0)
machine_tag (~> 2.0.0)
machine_tag (~> 2.0)
marker (>= 0.0.0)
ntp (>= 0.0.0)
rightscale_tag (~> 2.0.0)
rightscale_tag (~> 2.0)
rsyslog (>= 0.0.0)
swap (>= 0.0.0)
yum-epel (>= 0.0.0)
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ rs-application_php Cookbook CHANGELOG

This file is used to list changes made in each version of the rs-application_php cookbook.

v2.0.1
------
- adds azure rm support for private ips, issue: [#29][], PR: [#30][]

v2.0.0
------
- Chef 12 Migration - PR: [#27][]
Expand Down Expand Up @@ -55,5 +59,7 @@ v1.0.0
- Initial release

<!--- The following link definition list is generated by PimpMyChangelog --->
[#29]: https://github.com/rightscale-cookbooks/rs-application_php/issues/29
[#30]: https://github.com/rightscale-cookbooks/rs-application_php/issues/30
[#27]: https://github.com/rightscale-cookbooks/rs-application_php/issues/27
[#31]: https://github.com/rightscale-cookbooks/rs-application_php/issues/31
[#31]: https://github.com/rightscale-cookbooks/rs-application_php/issues/31
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://rubygems.org'

gem 'rake'
Expand Down
3 changes: 2 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rspec/core/rake_task'
require 'foodcritic'
require 'kitchen'
Expand Down Expand Up @@ -77,7 +78,7 @@ desc 'runs foodcritic linttask'
task :fc_new do
FoodCritic::Rake::LintTask.new(:chef) do |t|
t.options = {
fail_tags: ['any']
fail_tags: ['any'],
}
end
end
Expand Down
21 changes: 11 additions & 10 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
# -*- mode: ruby -*-
# vi: set ft=ruby :

Expand Down Expand Up @@ -71,37 +72,37 @@ Vagrant.configure('2') do |config|

config.vm.provision :chef_solo do |chef|
chef.json = {
:mysql => {
mysql: {
server_root_password: 'rootpass',
server_debian_password: 'debpass',
server_repl_password: 'replpass'
server_repl_password: 'replpass',
},
:vagrant => {
box_name: 'appserver'
vagrant: {
box_name: 'appserver',
},
:'rs-application_php' => {
'rs-application_php': {
application_name: 'example',
local_settings_file: 'config/db.php',
scm: {
provider: 'git',
revision: 'unified_php',
repository: 'git://github.com/rightscale/examples.git'
repository: 'git://github.com/rightscale/examples.git',
},
database: {
provider: 'mysql',
host: 'localhost',
user: 'app_user',
password: 'apppass',
schema: 'app_test'
}
}
schema: 'app_test',
},
},
}

chef.run_list = [
'recipe[apt]',
'recipe[mysql::server]',
'recipe[fake::database_mysql]',
'recipe[rs-application_php::default]'
'recipe[rs-application_php::default]',
]
end
end
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Cookbook Name:: rs-application_php
# Attribute:: default
Expand Down
35 changes: 29 additions & 6 deletions libraries/helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Cookbook Name:: rs-application_php
# Library:: helper
Expand Down Expand Up @@ -65,17 +66,39 @@ def self.split_by_package_name_and_version(packages)
def self.get_bind_ip_address(node)
case node['rs-application_php']['bind_network_interface']
when 'private'
if node['cloud']['private_ips'].nil? || node['cloud']['private_ips'].empty?
raise 'Cannot find private IP of the server!'
priv_ip = nil
if !node['cloud']['private_ips'].nil? && !node['cloud']['private_ips'].empty?
priv_ip = node['cloud']['private_ips'].first
end

node['cloud']['private_ips'].first
if !node['cloud_v2']['local_ipv4_addrs'].nil? && !node['cloud_v2']['local_ipv4_addrs'].empty? && priv_ip.nil?
priv_ip = node['cloud_v2']['local_ipv4_addrs'].first
end unless node['cloud_v2'].nil?

if priv_ip.nil? && IPAddress(node['ipaddress']).private?
priv_ip = node['ipaddress']
end

raise 'Cannot find private IP of the server!' if priv_ip.nil?

priv_ip
when 'public'
if node['cloud']['public_ips'].nil? || node['cloud']['public_ips'].empty?
raise 'Cannot find public IP of the server!'
public_ip = nil
if !node['cloud']['public_ips'].nil? && !node['cloud']['public_ips'].empty?
public_ip = node['cloud']['public_ips'].first
end

node['cloud']['public_ips'].first
if !node['cloud_v2']['public_ipv4_addrs'].nil? && !node['cloud_v2']['public_ipv4_addrs'].empty? && public_ip.nil?
public_ip = node['cloud_v2']['public_ipv4_addrs'].first
end unless node['cloud_v2'].nil?

if public_ip.nil? && !IPAddress(node['ipaddress']).private?
public_ip = node['ipaddress']
end

raise 'Cannot find public IP of the server!' if public_ip.nil?

public_ip
else
raise "Unknown network interface '#{node['rs-application_php']['bind_network_interface']}'!" \
" The network interface must be either 'public' or 'private'."
Expand Down
13 changes: 7 additions & 6 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# frozen_string_literal: true
name 'rs-application_php'
maintainer 'RightScale, Inc.'
maintainer_email '[email protected]'
license 'Apache 2.0'
description 'Installs/Configures a PHP application server'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '2.0.0'
version '2.0.1'
source_url 'https://github.com/rightscale-cookbooks/rs-application_php' if respond_to?(:source_url)
issues_url 'https://github.com/rightscale-cookbooks/rs-application_php/issues' if respond_to?(:issues_url)
chef_version '>= 12.0' if respond_to?(:chef_version)
Expand Down Expand Up @@ -47,7 +48,7 @@
recipes: [
'rs-application_php::default',
'rs-application_php::tags',
'rs-application_php::application_backend'
'rs-application_php::application_backend',
]

attribute 'rs-application_php/scm/repository',
Expand Down Expand Up @@ -79,7 +80,7 @@
'rs-application_php::default',
'rs-application_php::tags',
'rs-application_php::application_backend',
'rs-application_php::application_backend_detached'
'rs-application_php::application_backend_detached',
]

attribute 'rs-application_php/vhost_path',
Expand All @@ -91,7 +92,7 @@
required: 'required',
recipes: [
'rs-application_php::tags',
'rs-application_php::application_backend'
'rs-application_php::application_backend',
]

attribute 'rs-application_php/app_root',
Expand All @@ -101,7 +102,7 @@
required: 'optional',
recipes: [
'rs-application_php::default',
'rs-application_php::tags'
'rs-application_php::tags',
]

attribute 'rs-application_php/bind_network_interface',
Expand All @@ -113,7 +114,7 @@
required: 'optional',
recipes: [
'rs-application_php::default',
'rs-application_php::tags'
'rs-application_php::tags',
]

attribute 'rs-application_php/migration_command',
Expand Down
3 changes: 2 additions & 1 deletion recipes/application_backend.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Cookbook Name:: rs-application_php
# Recipe:: application_backend
Expand Down Expand Up @@ -45,7 +46,7 @@ class Chef::Recipe

remote_recipe 'HAProxy Frontend - chef' do
tags "load_balancer:active_#{node['rs-application_php']['application_name']}=true"
attributes('APPLICATION_BIND_IP' => "text:#{node['cloud']['private_ips'][0]}",
attributes('APPLICATION_BIND_IP' => "text:#{RsApplicationPhp::Helper.get_bind_ip_address(node)}",
'APPLICATION_BIND_PORT' => "text:#{node['rs-application_php']['listen_port']}",
'APPLICATION_SERVER_ID' => "text:#{node['rightscale']['instance_uuid']}",
'POOL_NAME' => "text:#{node['rs-application_php']['application_name']}",
Expand Down
1 change: 1 addition & 0 deletions recipes/application_backend_detached.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Cookbook Name:: rs-application_php
# Recipe:: application_backend_detached
Expand Down
1 change: 1 addition & 0 deletions recipes/collectd.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Cookbook Name:: rs-application_php
# Recipe:: collectd
Expand Down
9 changes: 7 additions & 2 deletions recipes/default.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Cookbook Name:: rs-application_php
# Recipe:: default
Expand Down Expand Up @@ -25,8 +26,12 @@

include_recipe 'yum-mysql-community::mysql57' if node['platform_family'] == 'rhel'

# include_recipe 'database::mysql'
mysql_client 'default' do
action :create
end

mysql2_chef_gem 'default' do
provider Chef::Provider::Mysql2ChefGem::Mysql
action :install
end

Expand Down Expand Up @@ -62,7 +67,7 @@
Chef::Log.info "web_app overrides(server_port:#{listen_port},allow_override:#{node['rs-application_php']['allow_override']}"
overrides = {
server_port: listen_port,
allow_override: node['rs-application_php']['allow_override']
allow_override: node['rs-application_php']['allow_override'],
}

# Set up application
Expand Down
1 change: 1 addition & 0 deletions recipes/tags.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Cookbook Name:: rs-application_php
# Recipe:: tags
Expand Down
1 change: 1 addition & 0 deletions spec/rs-application_php_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
require_relative 'spec_helper'
require_relative '../libraries/helper'

Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Cookbook Name:: rs-haproxy
# Spec:: spec_helper
Expand Down
1 change: 1 addition & 0 deletions test/cookbooks/fake/Berksfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'https://supermarket.chef.io'

metadata
1 change: 1 addition & 0 deletions test/cookbooks/fake/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
#
# Cookbook Name:: fake
# Attribute:: default
Expand Down
2 changes: 2 additions & 0 deletions test/cookbooks/fake/files/default/my.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[client]
socket = /var/run/mysql-default/mysqld.sock
2 changes: 2 additions & 0 deletions test/cookbooks/fake/files/default/mysql.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mysql]
mysql.default_socket = '/var/run/mysql-default/mysqld.sock'
4 changes: 4 additions & 0 deletions test/cookbooks/fake/metadata.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
name 'fake'
maintainer 'RightScale, Inc.'
maintainer_email '[email protected]'
Expand All @@ -6,6 +7,9 @@
version '0.1.0'

depends 'database'
depends 'mysql', '~> 8.2'
depends 'mysql2_chef_gem'
depends 'yum-mysql-community'

recipe 'fake::database_mysql', 'Prepares the test mysql database'
recipe 'fake::create_secrets', 'creates rightlink secrets'
1 change: 1 addition & 0 deletions test/cookbooks/fake/recipes/create_secrets.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
directory '/var/run/rightlink' do
owner 'root'
group 'root'
Expand Down
Loading

0 comments on commit a8890d1

Please sign in to comment.