Installing docker-ce through puppet - docker

Im trying to install docker-ce through puppet and i have a couple of questions.
1: Does apt::key automatically do a 'apt-get update' afterwards?
2: How can i use the apt:ppa module to add the docker-ce repository?
this is done with:
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
But how would i use the apt::ppa to include distribution and release?
This is the whole puppet block:
class docker {
$prerequisites = ['apt-transport-https', 'ca-certificates', 'curl']
package { $prerequisites: ensure => installed}
apt::key { 'docker-ce':
ensure => present,
id => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88',
options => 'https://download.docker.com/linux/ubuntu/gpg',
}
apt::ppa {''}
package {'docker-ce': ensure => installed}
}
EDIT:
Ended up using the apt module with apt::source, hardcoded release because i know all my systems will run it.
class docker {
include apt
$prerequisites = ['apt-transport-https', 'ca-certificates']
package { $prerequisites: ensure => installed} ->
apt::key { 'docker-ce':
ensure => present,
id => '9DC858229FC7DD38854AE2D88D81803C0EBFCD88',
options => 'https://download.docker.com/linux/ubuntu/gpg',
} ->
apt::source {'docker-ce':
location => 'https://download.docker.com/linux/ubuntu',
release => 'xenial'
} ->
exec { 'apt-get-update':
command => '/usr/bin/apt-get update'
} ->
package {'docker-ce': ensure => installed}
}

Here's how I'm installing this:
apt::key { '9DC858229FC7DD38854AE2D88D81803C0EBFCD88':
source => 'https://download.docker.com/linux/ubuntu/gpg',
} ->
apt::source { 'docker-ce':
architecture => 'amd64',
location => 'https://download.docker.com/linux/ubuntu',
repos => 'stable',
release => $::lsbdistcodename,
} ->
package { 'docker-ce':
ensure => 'latest',
require => Exec['apt_update'],
}

Related

How to add jobs in jenkins using puppet?

I have used the official puppet jenkins module. I have added jenkins jobs like this.
jenkins::job { 'test-build-job':
config => template("${templates}/test-build-job.xml.erb"),
}
when I run this command in puppet agent
puppet agent -tv
I get error like this:
Error: Failed to apply catalog: Validation of Exec[reload-jenkins] failed:
'java -jar /usr/lib/jenkins/jenkins-cli.jar -s http://localhost:8080
reload-configuration'
is not qualified and no path was specified. Please qualify the command or specify a path. (file: /etc/puppetlabs/code/environments/production/modules/jenkins/manifests/cli.pp, line: 42)
I'm getting error in cli.pp, and my cli.pp looks like
class jenkins::cli {
if $caller_module_name != $module_name {
fail("Use of private class ${name} by ${caller_module_name}")
}
$jar = "${jenkins::libdir}/jenkins-cli.jar"
$extract_jar = "jar -xf ${jenkins::libdir}/jenkins.war WEB-INF/jenkins-cli.jar"
$move_jar = "mv WEB-INF/jenkins-cli.jar ${jar}"
$remove_dir = 'rm -rf WEB-INF'
exec { 'jenkins-cli' :
command => "${extract_jar} && ${move_jar} && ${remove_dir}",
path => ['/bin', '/usr/bin'],
cwd => '/tmp',
creates => $jar,
require => Service['jenkins'],
}
file { $jar:
ensure => file,
require => Exec['jenkins-cli'],
}
$port = jenkins_port()
# The jenkins cli command with required parameter(s)
$cmd = "java -jar ${jar} -s http://localhost:${port}"
# Reload all Jenkins config from disk (only when notified)
exec { 'reload-jenkins':
command => "${cmd} reload-configuration",
tries => 10,
try_sleep => 2,
refreshonly => true,
require => File[$jar],
}
# Do a safe restart of Jenkins (only when notified)
exec { 'safe-restart-jenkins':
command => "${cmd} safe-restart && /bin/sleep 10",
tries => 10,
try_sleep => 2,
refreshonly => true,
require => File[$jar],
}
}

Vagrant SSH command responded with a non-zero exit status

I'm trying to install docker on Ubuntu 18.04-VM (via vagrant) using the setup below. Is there any way I can make docker installation succeed on vagrant ubuntu 18.04 VM using the Vagrantfile? Note: I need to know how to apply the suggested solution into the Vagrantfile.
Vagrantfile:
servers=[
{
:hostname => "manager",
:ip => "192.168.2.1",
:box => "ubuntu/bionic64",
:ram => 2048,
:cpu => 4
},
{
:hostname => "worker-1",
:ip => "192.168.2.2",
:box => "ubuntu/bionic64",
:ram => 2048,
:cpu => 4
},
{
:hostname => "worker-2",
:ip => "192.168.2.3",
:box => "ubuntu/bionic64",
:ram => 2048,
:cpu => 4
}
]
Vagrant.configure(2) do |config|
servers.each do |machine|
config.vm.define machine[:hostname] do |node|
node.vm.box = machine[:box]
node.vm.hostname = machine[:hostname]
node.vm.network "private_network", ip: machine[:ip]
if machine[:hostname] == "manager"
node.vm.provision "docker",
images: ["ubuntu/bionic64"]
else
node.vm.provision "docker"
end
node.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", machine[:ram]]
end
end
end
end
Dockerfile:
FROM ubuntu:18.04
RUN apt-get install -y python python-pip --no-install-recommends
RUN apt-get install vim -y
RUN apt update -y
ADD app /home/app/
WORKDIR /home/app
EXPOSE 8080
Exception/Error Output Message:
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
curl -sSL https://get.docker.com/ | sh
Stdout from the command:
Executing docker install script, commit: 02d7c3c
Stderr from the command:
Either your platform is not easily detectable or is not supported by this
installer script.
Please visit the following URL for more detailed installation instructions:
https://docs.docker.com/engine/installation/
I finally figured it out spawning virtual servers with Ubuntu 18, using Vagrant. The link has all the simple instructions: Spawn virtual servers on the fly

Push to Git using Rugged

I worked in a script to push to git using a script, so I choose Rugged to do that, my probleme when I try to push to repo, it gives me error, Can you help me ?
require 'rugged'
git_email = 'ettaheri.nizar#gmail.com'
git_name = 'Nizar'
repo_name = '/Users/euphor/Desktop/test/testignore1'
repo = Rugged::Repository.new('/Users/euphor/Desktop/test/testignore1')
puts "1"
index = repo.index
puts "3"
oid = repo.write("This is a blob.", :blob)
index.add(:path => "testignore1", :oid => oid, :mode => 0100644)
puts "4"
options = {}
options[:tree] = index.write_tree(repo)
puts "5"
options[:author] = { :email => git_email, :name => git_name, :time => Time.now }
options[:committer] = { :email => git_email, :name => 'Test Author', :time => Time.now }
puts "6"
options[:message] ||= "Making a commit via Rugged!"
options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact
options[:update_ref] = 'HEAD'
puts "7"
Rugged::Commit.create(repo, options)
puts "8"
**repo.push 'origin'** # this is my error
puts "Done"
the message of my error is :
/Library/Ruby/Gems/2.0.0/gems/rugged-0.23.0/lib/rugged/repository.rb:224:in
push': Unsupported URL protocol (Rugged::NetworkError) from
/Library/Ruby/Gems/2.0.0/gems/rugged-0.23.0/lib/rugged/repository.rb:224:in
push' from vips.rb:43:in `'
Looks like you have libgit2 (backend for Rugged) not installed properly. Most convenient packaging solution for Mac OS if Homebrew, and you need it to install additional libraries.
Install Homebrew
Follow any on-screen instructions after executing this line:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install openssh
brew install openssh
Reinstall rugged gem
gem uninstall rugged
gem install rugged
Now your snippet should run fine.

How can i install ONLY LTS version of Jenkins with puppet

I tried:
# jenkins.pp
class jenkins {
yumrepo { "jenkins":
baseurl => "http://pkg.jenkins-ci.org/redhat",
descr => "Jenkins",
enabled => 1,
gpgcheck => 1,
gpgkey => "http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key",
}
#package {"jenkins": ensure => latest}
package {"jenkins": ensure => "1.509.1"}
}
include jenkins
But it still installs the latest release, and not the LTS version, which is 1.509.1
You use invalid base url.
Try http://pkg.jenkins-ci.org/redhat-stable/. More Info see: link and this.

gstreamer plugin library not linking against opencv shared object library - “undefined symbol” on CentOS

I have a plugin that uses OpenCV and it works perfectly on Kubuntu. Now I am trying to run the code on CentOS but when I run the pipeline, I get:
$ gst-launch videotestsrc ! opencvelement ! ximagesink
WARNING: erroneous pipeline: no element "opencvelement"
When I run ldd in Kubuntu, I get:
$ ldd .libs/libOPENCVELEMENT.so
linux-gate.so.1 => (0x0060f000)
libgstbase-0.10.so.0 => /usr/lib/libgstbase-0.10.so.0 (0x00a74000)
libgstreamer-0.10.so.0 => /usr/lib/libgstreamer-0.10.so.0 (0x00474000)
libgobject-2.0.so.0 => /usr/lib/i386-linux-gnu/libgobject-2.0.so.0 (0x006a2000)
libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0 (0x00110000)
libopencv_core.so.2.3 => /usr/local/lib/libopencv_core.so.2.3 (0x00730000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0x00209000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0x002f4000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0x00acd000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0x0031e000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0x0033c000)
libgthread-2.0.so.0 => /usr/lib/i386-linux-gnu/libgthread-2.0.so.0 (0x00357000)
libgmodule-2.0.so.0 => /usr/lib/i386-linux-gnu/libgmodule-2.0.so.0 (0x0035d000)
libxml2.so.2 => /usr/lib/libxml2.so.2 (0x00c9c000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0x00362000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0x0036b000)
libffi.so.6 => /usr/lib/i386-linux-gnu/libffi.so.6 (0x00370000)
libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0x00e52000)
libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0x00377000)
/lib/ld-linux.so.2 (0x00a10000)
But when I run it on CentOS, I don't see opencv
$ ldd .libs/libOPENCVELEMENT.so
linux-vdso.so.1 => (0x00007fff7a1fd000)
libgstvideo-0.10.so.0 => /usr/lib64/libgstvideo-0.10.so.0 (0x00002ba0ac9b7000)
libgstcontroller-0.10.so.0 => /usr/lib64/libgstcontroller-0.10.so.0 (0x00002ba0acbc4000)
libgstbase-0.10.so.0 => /usr/lib64/libgstbase-0.10.so.0 (0x00002ba0acdeb000)
libgstreamer-0.10.so.0 => /usr/lib64/libgstreamer-0.10.so.0 (0x00002ba0ad03c000)
libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00002ba0ad326000)
libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00002ba0ad569000)
libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00002ba0ad76c000)
librt.so.1 => /lib64/librt.so.1 (0x00002ba0ad970000)
libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00002ba0adb7a000)
libz.so.1 => /lib64/libz.so.1 (0x00002ba0adeb7000)
libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00002ba0ae0cb000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00002ba0ae3a8000)
libm.so.6 => /lib64/libm.so.6 (0x00002ba0ae6a8000)
libc.so.6 => /lib64/libc.so.6 (0x00002ba0ae92b000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002ba0aec83000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ba0aee91000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002ba0af0ac000)
/lib64/ld-linux-x86-64.so.2 (0x0000003f6c800000)
Here is my makefile.am, which is the same on both OS
plugin_LTLIBRARIES = libOPENCVELEMENT.la
# Plugin source files:
libOPENCVELEMENT_la_SOURCES = opencv_chain.c opencv_chain.h datasetup.h
libOPENCVELEMENT_la_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_CFLAGS) \
$(OPENCV_CFLAGS)
libOPENCVELEMENT_la_CXXFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_CFLAGS) \
$(OPENCV_CFLAGS)
libOPENCVELEMENT_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) \
$(GST_LIBS) \
$(OPENCV_LIBS) \
-lopencv_core \
-lopencv_highgui
libOPENCVELEMENT_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libOPENCVELEMENT_la_LIBTOOLFLAGS = --tag=disable-static
Let me know if you need more information. Any help will be appreciated. Thank you.
Do you have all the opencv development files installed on centos as well. Run a:
grep "OPENVC_" Makefile
to check what the Make variables contain. Also you can pipe the linker (undefined symbol) output through c++filt to see the real function name instead of the mangled name.
I was able to solve this by going to /usr/lib64/pkgconfig and modified opencv.pc to explicitly have all libraries. I also had to move the plugins from /usr/lib/gstreamer-0.10 to /usr/lib64/gstreamer-0.10

Resources