Skip to content

Commit

Permalink
Add puppet scripts for APIM 320
Browse files Browse the repository at this point in the history
  • Loading branch information
VimukthiPerera authored and ctienshi committed Sep 8, 2020
1 parent e647919 commit eb7fc0a
Show file tree
Hide file tree
Showing 20 changed files with 1,544 additions and 1,190 deletions.
28 changes: 14 additions & 14 deletions pattern-1/pattern-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,15 @@ Resources:
- >-
/g"
/etc/puppet/code/environments/production/modules/apim/manifests/params.pp
- !Join
- ''
- - sed -i "s/CF_ELB_DNS_NAME/
- !GetAtt
- WSO2APIMLoadBalancer
- DNSName
- >-
/g"
/etc/puppet/code/environments/production/modules/apim_common/manifests/params.pp
- !Join
- ''
- - sed -i "s/CF_ELB_DNS_NAME/
Expand All @@ -458,24 +467,24 @@ Resources:
- ''
- - sed -i "s/CF_DB_USERNAME/
- !Ref DBUsername
- /g" /etc/puppet/code/environments/production/modules/apim/manifests/params.pp
- /g" /etc/puppet/code/environments/production/modules/apim_common/manifests/params.pp
- !Join
- ''
- - sed -i "s/CF_DB_PASSWORD/
- !Ref DBPassword
- /g" /etc/puppet/code/environments/production/modules/apim/manifests/params.pp
- /g" /etc/puppet/code/environments/production/modules/apim_common/manifests/params.pp
- !Join
- ''
- - sed -i "s/CF_DBMS/
- !Select [0, !Split ["_", !FindInMap [ DBEngineMap, !Ref DB, DBEngine]]]
- /g" /etc/puppet/code/environments/production/modules/apim/manifests/params.pp
- /g" /etc/puppet/code/environments/production/modules/apim_common/manifests/params.pp
- !Join
- ''
- - sed -i "s/CF_RDS_URL/
- !GetAtt
- WSO2APIMDBInstance
- Endpoint.Address
- /g" /etc/puppet/code/environments/production/modules/apim/manifests/params.pp
- /g" /etc/puppet/code/environments/production/modules/apim_common/manifests/params.pp
- !Join
- ''
- - sed -i "s/CF_DB_USERNAME/
Expand Down Expand Up @@ -545,7 +554,7 @@ Resources:
- ''
- - sed -i "s/JDK_TYPE/
- !Ref JDK
- /g" /etc/puppet/code/environments/production/modules/apim/manifests/params.pp
- /g" /etc/puppet/code/environments/production/modules/apim_common/manifests/params.pp
- !Join
- ''
- - sed -i "s/JDK_TYPE/
Expand Down Expand Up @@ -1240,15 +1249,6 @@ Resources:
/opt/puppetlabs/bin/puppet agent -vt >> /var/log/puppetlog.log
fi
sleep 30
mkdir /root/.aws
echo "[default]" >> /root/.aws/credentials
echo "aws_access_key_id = ${AWSAccessKeyId}" >> /root/.aws/credentials
echo "aws_secret_access_key = ${AWSAccessKeySecret}" >> /root/.aws/credentials
cd /home/ubuntu/
wget https://wso2-cloudformation-templates.s3.amazonaws.com/certificate_extractor.py
sed -i "s/CERTIFICATE_NAME/${CertificateName}/g" /home/ubuntu/certificate_extractor.py
python certificate_extractor.py
keytool -noprompt -import -trustcacerts -keystore /usr/lib/wso2/wso2am-analytics/3.0.0/wso2am-analytics-3.0.0/resources/security/client-truststore.jks -file certificate.crt -keypass wso2carbon -storepass wso2carbon -alias ssl-cert
/usr/lib/wso2/wso2am-analytics/3.0.0/wso2am-analytics-3.0.0/bin/dashboard.sh start
if [[ ${OperatingSystem} == "Ubuntu1804" ]]; then
/usr/local/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource WSO2APIMAnalyticsDashboardAutoScalingGroup --region ${AWS::Region}
Expand Down
162 changes: 35 additions & 127 deletions pattern-1/puppet/apim/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,147 +16,55 @@

# Class: apim
# Init class of API Manager default profile
class apim (
$user = $apim::params::user,
$user_id = $apim::params::user_id,
$user_group = $apim::params::user_group,
$user_group_id = $apim::params::user_group_id,
$service_name = $apim::params::service_name,
$template_list = $apim::params::template_list,
$start_script_template = $apim::params::start_script_template,
class apim inherits apim::params {

# api-manager.xml configs
$auth_manager = $apim::params::auth_manager,
$api_gateway = $apim::params::api_gateway,
$analytics = $apim::params::analytics,
$api_store = $apim::params::api_store,
$api_publisher = $apim::params::api_publisher,
include apim_common

# Master-datasource configs
$wso2am_db = $apim::params::wso2am_db,
$wso2am_stat_db = $apim::params::wso2am_stat_db,
$wso2_mb_store_db = $apim::params::wso2_mb_store_db,

# carbon.xml configs
$ports = $apim::params::ports,
$key_store = $apim::params::key_store,
)

inherits apim::params {

# Create wso2 group
group { $user_group:
ensure => present,
gid => $user_group_id,
system => true,
}

# Create wso2 user
user { $user:
ensure => present,
uid => $user_id,
gid => $user_group_id,
home => "/home/${user}",
system => true,
}
# Ensure the installation directory is available
file { "/opt/${service_name}":
ensure => 'directory',
owner => $user,
group => $user_group,
}

file { "/usr/lib/wso2/":
ensure => directory,
owner => $user,
group => $user_group,
}

file { "/usr/lib/wso2/wso2am/":
ensure => directory,
owner => $user,
group => $user_group,
}

file { "/usr/lib/wso2/wso2am/3.0.0/":
ensure => directory,
owner => $user,
group => $user_group,
}

# Copy the relevant installer to the /opt/is directory
file { "/usr/lib/wso2/wso2am/3.0.0/${am_package}":
owner => $user,
group => $user_group,
mode => '0644',
source => "puppet:///modules/installers/${am_package}",
}

# Install WSO2 Identity Server
exec { 'unzip':
command => 'unzip wso2am-3.0.0.zip',
cwd => '/usr/lib/wso2/wso2am/3.0.0/',
path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
}

#jdk
file { "/usr/lib/wso2/wso2am/3.0.0/jdk-8u192-ea-bin-b02-linux-x64-19_jul_2018.tar.gz":
owner => $user,
group => $user_group,
mode => '0644',
source => "puppet:///modules/installers/jdk-8u192-ea-bin-b02-linux-x64-19_jul_2018.tar.gz",
# Copy configuration changes to the installed directory
$template_list.each |String $template| {
file { "${carbon_home}/${template}":
ensure => file,
mode => '0644',
content => template("${module_name}/carbon-home/${template}.erb"),
# notify => Service["${wso2_service_name}"],
require => Class["apim_common"]
}
}

# Install WSO2 Identity Server
exec { 'tar':
command => 'tar -xvf jdk-8u192-ea-bin-b02-linux-x64-19_jul_2018.tar.gz',
cwd => '/usr/lib/wso2/wso2am/3.0.0/',
path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
# Copy files to carbon home directory
$file_list.each | String $file | {
file { "${carbon_home}/${file}":
ensure => present,
owner => $user,
recurse => remote,
group => $user_group,
mode => '0755',
source => "puppet:///modules/${module_name}/${file}",
# notify => Service["${wso2_service_name}"],
require => Class["apim_common"]
}
}


# Copy configuration changes to the installed directory
$template_list.each | String $template | {
file { "/usr/lib/wso2/wso2am/3.0.0/wso2am-3.0.0/${template}":
ensure => file,
owner => $user,
group => $user_group,
mode => '0644',
content => template("${module_name}/carbon-home/${template}.erb")
# Delete files to carbon home directory
$file_removelist.each | String $removefile | {
file { "${carbon_home}/${removefile}":
ensure => absent,
owner => $user,
group => $user_group,
# notify => Service["${wso2_service_name}"],
require => Class["apim_common"]
}
}

# Copy wso2server.sh to installed directory
file { "/usr/lib/wso2/wso2am/3.0.0/wso2am-3.0.0/${start_script_template}":
file { "${carbon_home}/${start_script_template}":
ensure => file,
owner => $user,
group => $user_group,
mode => '0754',
content => template("${module_name}/carbon-home/${start_script_template}.erb")
}

# Copy mysql connector to the installed directory
file { "/usr/lib/wso2/wso2am/3.0.0/wso2am-3.0.0/repository/components/lib/${db_connector}":
owner => $user,
group => $user_group,
mode => '0754',
source => "puppet:///modules/installers/${db_connector}",
}

file { "/usr/local/bin/private_ip_extractor.py":
owner => $user,
group => $user_group,
mode => '0754',
source => "puppet:///modules/installers/private_ip_extractor.py",
}

# Copy the unit file required to deploy the server as a service
file { "/etc/systemd/system/${service_name}.service":
ensure => present,
owner => root,
group => root,
mode => '0754',
content => template("${module_name}/${service_name}.service.erb"),
content => template("${module_name}/carbon-home/${start_script_template}.erb"),
# notify => Service["${wso2_service_name}"],
require => Class["apim_common"]
}

/*
Expand Down
Loading

0 comments on commit eb7fc0a

Please sign in to comment.