Requiring apt::source as a dependency gives a syntax error - docker

I need to add the docker source list to apt before installing docker.
I have
apt::source { 'debian-jessie':
comment => 'This is the docker Debian jessie mirror',
location => 'http://apt.dockerproject.org/repo',
release => 'debian-jessie',
repos => 'main',
key_content => '58118E89F3A912897C070ADBF76221572C52609D',
key_server => 'keyserver.ubuntu.com',
ensure => present,
include_src => false,
include_deb => true,
}
which works, and also
package {'docker-engine':
ensure => present,
before => Class['docker'],
}
which works only after a second run (I use vagrant provision, but that's not relevant to the problem).
What I would like is making the whole thing work at the first provisioning by instructing puppet to execute apt::source before docker-engine, however adding it in require is not a valid syntax:
package {'docker-engine':
ensure => present,
before => Class['docker'],
require => [
Apt::source['debian-jessie'],
]
}
How to specify this dependency?
The rest of the file looks like this:
class { 'docker':
dns => '192.168.1.1',
manage_package => false,
use_upstream_package_source=> false,
# service_name => 'docker',
docker_command => 'docker',
package_name => 'docker-engine',
service_enable => true,
service_state => 'running',
extra_parameters => ["--insecure-registry=192.168.1.0/24"],
}
include 'docker'
file { "/lib/systemd/system/docker.service":
notify => Service["docker"],
ensure => present,
owner => "root",
group => "root",
mode => 0600,
source =>"puppet:///modules/docker/etc/systemd/system/docker.service"
} ~> Exec['systemctl-daemon-reload']

Capitalize word source
require => Apt::Source['debian-jessie']
Puppet documentation states:
The general form of a resource reference is:
The resource type, capitalized (every segment must be capitalized if
the resource type includes a namespace separator [::])
An opening square bracket
The title of the resource as a string, or a comma-separated list of titles
A closing square bracket

Related

Jira: Add new Released Version via API

We're trying to automate this task in our release process so that our scripts add a new released version in Jira. It will then iterate through a list of jira issues that have 'shipped' in this release and tag them with the Release Version we just added.
I can't seem to find any examples of adding a new Released Version in Jira [Project > Releases] via REST API.
Can you please share how you are handling this?
Add new Released Version via Jira API code snippet using ruby with httparty.
require 'httparty'
def self.create_version(version)
create_version_url = "https://jira2.server.com/rest/api/2/version"
#result = HTTParty.post(create_version_url,
:basic_auth => {:username => 'user', :password => 'password'},
:body => { :description => '',
:name => version,
:archived => false,
:released => true,
#:releaseDate => "2016-07-06",
:userReleaseDate => "6/Jul/2017",
:project => "project_name",
:projectId => "10102"
}.to_json,
:headers => { 'Content-Type' => 'application/json' })
puts #result
end
Set Fixed Version of jira issue:
def self.set_issue_fixedVersion(ticket,fixedVersion)
edit_issue_url = "https://jira2.<server>.com/rest/api/2/issue/#{ticket}"
#result = HTTParty.put(edit_issue_url,
:basic_auth => {:username => 'user', :password => 'password'},
:body => { "fields" => { "fixVersions"=> [{"name" => #{fixedVersion}}]}}.to_json,
:headers => { 'Content-Type' => 'application/json' })
puts #result
end
Could be something like this:
Create the new version: POST /version
You will also have to specify the project that the version belongs to
This will also make the version show up on the Project -> Releases page
Search for fixed issues, so you have their issue keys: POST /search
Possibly you can also get this list in another way, ie. from your version control system
Update the fixVersion of those issues with your new version: /PUT issue/{issueIdOrKey}
Release your version: PUT /version/{id}
In the body of your request specify the releaseDate and set released to true

How to distinguish between Rails and Rake at the initializers level?

Whether I execute rails or rake, the code present in the initializers folder will be executed. What I want to do is to make sure that the code in a given initializer file doesn't get fired up when running a rake task (hence only when Rails server or console are launched).
For example, I'd like to be able to do something like (in config/initializers/blabla.rb):
do_something # code always executed
unless ENV['rake']
something_when_not_rake # code executed only if rails server or console
end
do_something_more # more code always executed
I've been looking into the ENV variable to see what's available there but I've seen nothing interesting, here's the content (in the format "key" => "value"):
"rvm_bin_path" => "/Users/lucke84/.rvm/bin"
"GEM_HOME" => "/Users/lucke84/.rvm/gems/ruby-2.2.3"
"SHELL" => "/bin/bash"
"TERM" => "xterm-256color"
"TMPDIR" => "/var/folders/73/q8t0jjrx3zb8zvd072dgq11c0000gn/T/"
"IRBRC" => "/Users/lucke84/.rvm/rubies/ruby-2.2.3/.irbrc"
"Apple_PubSub_Socket_Render" => "/private/tmp/com.apple.launchd.mF5Uh4NPbk/Render"
"MY_RUBY_HOME" => "/Users/lucke84/.rvm/rubies/ruby-2.2.3"
"USER" => "lucke84"
"rvm_stored_umask" => "0022"
"_system_type" => "Darwin"
"rvm_path" => "/Users/lucke84/.rvm"
"SSH_AUTH_SOCK" => "/private/tmp/com.apple.launchd.ryhqrdVtVU/Listeners"
"__CF_USER_TEXT_ENCODING" => "0x1F5:0x0:0x0"
"rvm_prefix" => "/Users/lucke84"
"PATH" => "/Users/lucke84/.rvm/gems/ruby-2.2.3/bin:/Users/lucke84/.rvm/gems/ruby-2.2.3#global/bin:/Users/lucke84/.rvm/rubies/ruby-2.2.3/bin:/Users/lucke84/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/apache-maven/apache-maven-3.3.1/bin"
"rvm_loaded_flag" => "1"
"PWD" => "/Users/lucke84/projects/website"
"JAVA_HOME" => "/Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home"
"XPC_FLAGS" => "0x0"
"_system_arch" => "x86_64"
"_system_version" => "10.11"
"XPC_SERVICE_NAME" => "0"
"rvm_version" => "1.26.11 (latest)"
"HOME" => "/Users/lucke84"
"SHLVL" => "1"
"rvm_ruby_string" => "ruby-2.2.3"
"LOGNAME" => "lucke84"
"LC_CTYPE" => "en_US.UTF-8"
"GEM_PATH" => "/Users/lucke84/.rvm/gems/ruby-2.2.3:/Users/lucke84/.rvm/gems/ruby-2.2.3#global"
"rvm_delete_flag" => "0"
"RUBY_VERSION" => "ruby-2.2.3"
"_system_name" => "OSX"
"rvm_user_install_flag" => "1"
"BUNDLE_GEMFILE" => "/Users/lucke84/projects/website/Gemfile"
"_ORIGINAL_GEM_PATH" => "/Users/lucke84/.rvm/gems/ruby-2.2.3:/Users/lucke84/.rvm/gems/ruby-2.2.3#global"
"BUNDLE_BIN_PATH" => "/Users/lucke84/.rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/bin/bundle"
"RUBYOPT" => "-rbundler/setup"
"RUBYLIB" => "/Users/lucke84/.rvm/gems/ruby-2.2.3/gems/bundler-1.10.6/lib"
"MANPATH" => "/Users/lucke84/.rvm/gems/ruby-2.2.3/gems/unicorn-5.0.1/man"
I cannot find a built-in environment key/value to programmatically determine who is triggering the command. Maybe one of you can shed some light on this topic for me?
Further details:
this cannot be an environment-dependent check, it should work for development as well as for production (or whatever the environment)
I would like to avoid to specify a custom parameter (i.e. bin/rake my:task skip_initializer=true), as what I'm trying to do is to skip that initializer's executions for all rake tasks
running Rails 4.2.x at the moment
Thanks in advance for your help!

Database driver Cake\Database\Driver\Sqlserver cannot be used due to a missing PHP extension or unmet dependency

I have installed cakephp 3.0.10 having mssql database now i have configured my wamp (php 5.5.12) with
extension=php_sqlsrv_55_ts.dll
extension=php_pdo_sqlsrv_55_ts.dll
& php info showing that sqlsrv is configured.
I have configured App.php with following code
'default' => [
'className' => 'Cake\Database\Connection',
'driver' => 'Cake\Database\Driver\Sqlserver',
'persistent' => true,
'host' => 'mypc\SQLEXPRESS',
'username' => '',
'password' => '',
'database' => 'testdbname',
'encoding' => 65001,//PDO::SQLSRV_ENCODING_UTF8,
'timezone' => 'UTC',
'cacheMetadata' => true,
'quoteIdentifiers' => false,
To check whether connection is working or not i created a index.php file and fetched data from a test db created in sql magt. 2012 Now problem is cake php is not getting connected with database and it is showing following error
Database driver Cake\Database\Driver\Sqlserver cannot be used due to a missing PHP extension or unmet dependency
Exception Attributes: array (
'driver' => 'Cake\\Database\\Driver\\Sqlserver',
)
crud operation are going well in index.php ( test file ) but cakephp flashing error
Please help me to sort this out.
Thanks in advance

HBase via MassiveRecord in Ruby is causing an abort

When using MassiveRecord over thrift to save a record into HBase, I get a strange "abort" error.
Here is some code that will reproduce the error on Mac OS X, with hbase (0.92.0 and 0.94.0) install via homebrew.
require 'massive_record'
MassiveRecord::ORM::Base.connection_configuration = { :host => 'hbase' }
class Woot < MassiveRecord::ORM::Table
default_scope select(:data)
column_family :data do
field :name, :string
end
end
woot = Woot.new( :name => 'rawr' )
woot.save
This always causes the process to halt, leaving the message
[1] 8756 abort ruby massive_woot.rb
Retrieving works just fine, but I can't seem to save the records.
Here is what the schema looks like:
>> describe 'woots'
DESCRIPTION ENABLED
{NAME => 'woots', FAMILIES => [{NAME => 'data', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSIONS => '3', C true
OMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCA
CHE => 'true'}]}
1 row(s) in 0.0190 seconds
This turned out to be a versioning issue. MassiveRecord v0.2.2 depends on thrift 0.6.0 (specified by an "= 0.6.0" version in the Gemfile).
I solved this for now by pulling off the "develop" branch of MassiveRecord from github.

Ruby add_item for eBay

I am attempting to write a ruby on rails app that posts an item to eBay. Cody Fauser/Garry Tan have a gem called ebayApi which is built on top of the ebay gem. When I attempt to post an item, I am getting an error back from ebay that says the condition ID is required for this category. I have found a category that does not require the condition, and I can post to that category. Searching through the eBay API documentation, I have found a tag conditionID under the "item" class. However, in the documentation for ebayAPI, there is no such tag. Looking back at the ebay API documentation, there is an older way to specify condition, using lookup_attributes. I have noted that the return xml is coming in API version 745, and Garry Gan's updated of the ruby interface is running version 609. I have tried using the lookup, and seem to get the same error (condition required). I am using the following code to specify the item:
#ebay = Ebay::Api.new :auth_token => #seller.ebay_token
item = Ebay::Types::Item.new( :primary_category => Ebay::Types::Category.new(:category_id => #ebayTemplate.categoryID),
:title => #ebayTemplate.name,
:description => #ebayTemplate.description,
:location => #ebayTemplate.location,
:start_price => Money.new((#ebayTemplate.startPrice*100).to_d, #ebayTemplate.currency),
:quantity => 1,
:listing_duration => #ebayTemplate.listingDuration,
:country => #ebayTemplate.country,
:currency => #ebayTemplate.currency,
:payment_methods => ['VisaMC', 'PayPal'],
:paypal_email_address => '********#gmail.com',
:dispatch_time_max => 3,
:lookup_attributes => [Ebay::Types::LookupAttribute.new( :name => "Condition", :value => "New")],
# :attribute_sets => [
# Ebay::Types::AttributeSet.new(
# :attribute_set_id => 2919,
# :attributes => [
# Ebay::Types::Attribute.new(
# :attribute_id => 10244,
# :values => [ Ebay::Types::Val.new(:value_id => 10425) ]
# )
# ]
# )
# ],
:shipping_details => Ebay::Types::ShippingDetails.new(
:shipping_service_options => [
# ShippingServiceOptions.new(
# :shipping_service_priority => 2, # Display priority in the listing
# :shipping_service => 'UPSNextDay',
# :shipping_service_cost => Money.new(1000, 'USD'),
# :shipping_surcharge => Money.new(299, 'USD')
# ),
Ebay::Types::ShippingServiceOptions.new(
:shipping_service_priority => 1, # Display priority in the listing
:shipping_service => #ebayTemplate.shipSvc,
:shipping_service_cost => Money.new((#ebayTemplate.shipSvcCost*100).to_d, #ebayTemplate.currency),
:shipping_surcharge => Money.new((#ebayTemplate.shipSurcharge*100).to_d, #ebayTemplate.currency)
)
],
:international_shipping_service_options => [
Ebay::Types::InternationalShippingServiceOptions.new(
:shipping_service => 'USPSPriorityMailInternational',
:shipping_service_cost => Money.new((#ebayTemplate.shipSvcCost*100).to_d, #ebayTemplate.currency),
:shipping_service_priority => 2,
:ship_to_location => #ebayTemplate.shipToLocation
)
]
),
:return_policy => Ebay::Types::ReturnPolicy.new (
:description => 'this product for suckers only!',
:returns_accepted_option => 'ReturnsAccepted'
)
#:condition_id => 1000
)
#response = #ebay.add_item(:item => item)
As you can see, it is just a mutation of the example given by Cody Fauser. The condition_id at the bottom will bring up an error as there is no such attribute. It seems to me there is no facility for this in the gem since the requirement came into existence after the gem was created. I have not been able to find any other gems to connect with ebay. I have also noticed, there are very little complaints about this even though people are still downloading the gem (10 people downloaded it today). I think there are quite a number of people writing for ebay. Is there a key word I am missing to specify the condition? A work around that people have been using? Another gem I have missed?
There is an existing item_conditions_codes.rb in the gem's type directory and only has two values New and Used. Guess you could add more values in there. However still needs mapping to ID's per the updating (and changed from Attributes) method
You have to modify in the gem library in .. ruby/1.8/gems/ebayapi-0.12.0/lib/ebay/types/item.rb
and add the following new lines
# added to allow ConditionID to be pushed into XML
numeric_node :condition_id, 'ConditionID', :optional => true
then in your ruby ebay code use the following convention
:condition_id => 1500,
At least that seems to work for me right now.

Resources