install mongo with chef - mongodb

I've tried to figure out how to install a mongodb 3.4 instance using this chef cookbook. Nevertheless, I've not able to get to install it.
This is my mongodb.rb file content:
node.default['mongodb']['package_version'] = '3.4'
include_recipe 'mongodb::default'
And my metadata.db: depends 'mongodb', '~> 0.16.2'.
I've tried to verify it on centos-72 platform using kitchen verify centos-72. I'm getting this message:
ERROR: yum_package[mongodb-org] (mongodb::install line 77) had an error: Chef::Exceptions::Package: Version ["3.4"] of ["mongodb-org"] not found. Did you specify both version and release? (version-release, e.g. 1.84-10.fc6)
I'm realizing this cookbook tries to add this yum_repository:
yum_repository 'mongodb' do
description 'mongodb RPM Repository'
baseurl "http://downloads-distro.mongodb.org/repo/redhat/os/#{node['kernel']['machine'] =~ /x86_64/ ? 'x86_64' : 'i686'}"
action :create
gpgcheck false
enabled true
end
And according to this mongo documentation the link repository should have to be:
https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
instead of
"http://downloads-distro.mongodb.org/repo/redhat/os/..."

The repo you are using does not have version 3.4 available. You can verify this manually by just looking at the RPMs in http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/RPMS/

Related

How to use Kubectl commands to Acess a Rancher Cluster through Ansible

I am currently developing a project where I need to get the pod names of a Kubernetes Cluster running on Rancher using Ansible. The main thing here is that I have a couple of problems that are preventing me from advance.
I am currently executing a playbook to try to retrieve this information, instead of running a CLI command, because I want to manipulate those Rancher machines later one (e.g. install an rpm file).
Here is the playbook that I am executing tot try to retrieve the pods' names from Rancher:
---
- hosts: localhost
connection: local
remote_user: root
roles:
- role: ansible.kubernetes-modules
- role: hello-world
vars:
ansible_python_interpreter: '{{ ansible_playbook_python }}'
collections:
- community.kubernetes
tasks:
-
name: Gather openShift Dependencies
python_requirements_facts:
dependencies:
- openshift
-
name: Get the pods in the specific namespace
k8s_info:
kubeconfig: '/etc/ansible/RCCloudConfig'
kind: Pod
namespace: redmine
register: pod_list
-
name: Print pod names
debug:
msg: "pod_list: {{ pod_list | json_query('resources[*].status.podIP') }} "
- set_fact:
pod_names: "{{pod_list|json_query('resources[*].metadata.name')}}"
The problem is that I am getting a Kubernetes module error each time I am trying to run the playbook:
ERROR! the role 'ansible.kubernetes-modules' was not found in community.kubernetes:ansible .legacy:/etc/ansible/roles:/home/jcp/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/ roles:/etc/ansible
The error appears to be in '/etc/ansible/GetKubectlPods': line 7, column 7, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
roles:
- role: ansible.kubernetes-modules
^ here
If I remove that line on the code, Where I try to retrieve that role, I still get a similar error:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'kubernetes'
fatal: [localhost]: FAILED! => {"changed": false, "error": "No module named 'kubernetes'", "msg": "Failed to import the required Python library (openshift) on localhost.localdomain's Python /usr/bin/python3.6. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}
I have already tried to install ansible-galaxy kubernetes module on the machine and openshift.
Not sure what I am doing wrong since there are so many possibilities for what could be going wrong here.
Ansible Version Output:
ansible 2.9.9
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/jcp/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/jcp/.local/lib/python3.6/site-packages/ansible
executable location = /home/jcp/.local/bin/ansible
python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]
I've debugged my python_required_info output from openshift dependencies and this is what I have:
ok: [localhost] => {
"openshift_dependencies": {
"changed": false,
"failed": false,
"mismatched": {},
"not_found": [],
"python": "/usr/bin/python3.6",
"python_system_path": [
"/tmp/ansible_python_requirements_info_payload_5_kb4a7s/ansible_python_requirements_info_payloa d.zip",
"/usr/lib64/python36.zip",
"/usr/lib64/python3.6",
"/usr/lib64/python3.6/lib-dynload",
"/home/jcp/.local/lib/python3.6/site-packages",
"/usr/local/lib/python3.6/site-packages",
"/usr/local/lib/python3.6/site-packages/openshift-0.10.0.dev1-py3.6.egg",
"/usr/lib64/python3.6/site-packages",
"/usr/lib/python3.6/site-packages"
],
"python_version": "3.6.8 (default, Nov 21 2019, 19:31:34) \n[GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]" ,
"valid": {
"openshift": {
"desired": null,
"installed": "0.10.0.dev1"
}
}
}
}
Thanks for your help in advance!
Edit: The below answer was given for OP's specific Ansible version (i.e. 2.9.9) and is still valid if you still use it. Since version 2.10, you also need to install the relevant ansible collection if not already present
ansible-galaxy collection install kubernetes.core
See the latest module documentation for more information
In Ansible 2.9.9, you're not supposed to do anything special to use the module except installing the needed python dependencies. See the module documentation for your Ansible version
remove the line - role: ansible.kubernetes-modules, unless it is a module of yours in which case you have to tell us more because this is not a correct declaration.
remove the collection declaration
Add the following task somewhere before using the module:
- name: Make sure python deps are installed
pip:
name: openshift
Your actual python_requirement_facts task is doing nothing else than reporting the dependency is not found. Register the result and debug it to see for yourself.
Now use the k8s_info module normally.

uninitialized constant Mongoid::Slug

this is my first development on rails, so Im still learning. I'm having a problem with mongoid_slug. In my local development mongoid_slug works fine, but when I test it on production I'm having this error:
uninitialized constant Mongoid::Slug
This is my full trace: http://pastebin.com/7x0q5VwY
If I try to save the document error appears.
This is my GemFile:
gem 'rails', '4.0.0'
gem 'mongoid', '~> 4.0.0.beta1', github: 'mongoid/mongoid'
gem 'bson_ext'
gem 'cancan'
gem 'ckeditor'
gem 'mongoid_slug', '3.2'
gem 'sass-rails', '~> 4.0.0'
gem 'bootstrap-sass', '~> 3.1.1'
This is my model:
class Noticium
include Mongoid::Document
include Mongoid::Slug
field :titulo, type: String
slug :titulo, history: true
field :contenido, type: String
field :imagen, type: String
field :imagen_url, type: String
field :tipo, type: String
field :fecha_registro, type: DateTime
validates :titulo, uniqueness: true
validates :titulo, :contenido, :imagen_url, :tipo, presence: true
end
This is part of my controller where the error appears:
private
def set_noticium
#noticium = Noticium.find(params[:id])
end
def noticium_params
params.require(:noticium).permit(:titulo, :contenido, :imagen, :tipo,
:fecha_registro)
end
I have read related info but I can't figure out what could be wrong.
My website is hosted on Digital Ocean, I have checked the version of Rails, Ruby and mongodb they are the same that in my local machine.
Could someone help me to figure whats going on? Why on my local development the slug field is working and on production im having errors.
Thanks in advance.
Maybe the MongoID version?
http://rubygems.org/gems/mongoid_slug
Runtime Dependencies
mongoid > 3.0
And you are using Mongoid 4.0
Update: see this issue on Github: https://github.com/digitalplaywright/mongoid-slug/issues/30
My bad. Have to release master, which works without requiring the
path, to RubyGems.

Ruby gem loaded but still gives "uninitialized constant"

I don't understand this output:
$ rails c
Loading development environment (Rails 3.2.14)
1.9.3p392 :001> require 'rubygems'
=> false
1.9.3p392 :002 > require 'mongo'
=> false
1.9.3p392 :003 > include Mongo
=> Object
1.9.3p392 :004 > Mongo::VERSION
=> "1.6.0"
1.9.3p392 :005 > c = MongoClient.new
NameError: uninitialized constant MongoClient
from (irb):5
Clearly bundler is running correctly and loading the MongoDB driver gem "mongo" (version 1.6, which should be fine).
Yet when I try to reference MongoClient according to the docs, I get "uninitialized constant." The same happens if I try to reference it as Mongo::MongoClient.new
What am I missing here?
From your console output, you are using MongoDB Ruby driver version 1.6.0.
The corresponding API docs can be found here.
http://api.mongodb.org/ruby/1.6.0/
Version 1.6.0 uses the old Mongo::Connection class to connect to MongoDB.
The MongoClient class is new as of version 1.8.0, and so is not available in any older version.
Please use the matching API and documentation.
Please consider upgrading to newer versions of the mongo_mapper (0.12.0) and mongo (1.9.2) gems.

Running meteor from a checkout

I'm trying to run meteor from a checkout following the instructions on the main README: https://github.com/meteor/meteor (under Slow Start.) I'm trying to run the devel branch.
When running normal meteor, it starts up a mongo instance using the database stored in the .meteor directory of the current project. However, the checked out version throws the following error:
W20130729-16:18:46.369(-4)?(STDERR) /home/mao/projects/CrowdMapper/.meteor/local/build/programs/server/boot.js:184
W20130729-16:18:46.370(-4)?(STDERR) }).run();
W20130729-16:18:46.371(-4)?(STDERR) ^
W20130729-16:18:46.393(-4)?(STDERR) Error: MONGO_URL must be set in environment
W20130729-16:18:46.395(-4)?(STDERR) at packages/mongo-livedata/remote_collection_driver.js:32
W20130729-16:18:46.395(-4)?(STDERR) at _.once (packages/underscore/underscore.js:704)
W20130729-16:18:46.396(-4)?(STDERR) at new Meteor.Collection (packages/mongo-livedata/collection.js:65)
W20130729-16:18:46.396(-4)?(STDERR) at packages/service-configuration/service_configuration_common.js:8
W20130729-16:18:46.397(-4)?(STDERR) at packages/service-configuration.js:42:4
W20130729-16:18:46.397(-4)?(STDERR) at packages/service-configuration.js:51:3
W20130729-16:18:46.397(-4)?(STDERR) at mains (/home/mao/projects/CrowdMapper/.meteor/local/build/programs/server/boot.js:153:10)
W20130729-16:18:46.399(-4)?(STDERR) at Array.forEach (native)
W20130729-16:18:46.400(-4)?(STDERR) at Function._.each._.forEach (/home/mao/projects/meteor/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
W20130729-16:18:46.400(-4)?(STDERR) at /home/mao/projects/CrowdMapper/.meteor/local/build/programs/server/boot.js:80:5
How can I tell this version to use the project-local mongo database and start its own mongo instance as before?
This was caused by a breaking change in the devel branch as documented here:
https://groups.google.com/forum/#!topic/meteor-core/xtTlpFqp4to
This is because Meteor 0.6.5-rc's and later don't automatically include core dependencies that were listed for free before. It can be fixed with
meteor add standard-app-packages
or
meteor run-upgrader app-packages

Can't run Capistrano - dependency error

I've installed Capistrano on my Ubuntu with the following commands
sudo gem install capistrano
sudo gem install railsless-deploy # I want to deploy a PHP website
sudo gem install capistrano-ext
When I run "capify ." in my deployment folder, have got an error:
Same error with other Capistrano command like a simple "cap -h" ...
/usr/lib/ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find capistrano (>= 0) amongst [POpen4-0.1.4, Platform-0.4.0, addressable-2.3.4, addressable-2.3.2, bundler-1.3.5, bundler-1.2.3, bundler-1.0.21, chunky_png-1.2.8, chunky_png-1.2.7, coderay-1.0.9, coderay-1.0.8, commonjs-0.2.6, compass-0.12.2, compass-normalize-1.4.3, compass-normalize-1.4.2, compass-recipes-0.3.0, em-websocket-0.5.0, em-websocket-0.4.0, eventmachine-1.0.3, eventmachine-1.0.0, ffi-1.7.0, ffi-1.3.1, forge-0.5.0, formatador-0.2.4, fssm-0.2.10, fssm-0.2.9, guard-1.8.0, guard-1.7.0, guard-1.6.1, guard-1.3.3, guard-livereload-1.3.0, guard-livereload-1.2.1, guard-livereload-1.1.3, guard-livereload-1.0.1, hike-1.2.2, hike-1.2.1, http_parser.rb-0.5.3, json-1.7.7, json-1.7.6, json-1.6.5, less-2.3.2, less-2.2.2, less-2.0.8, libv8-3.16.14.1, libv8-3.11.8.13-x86-linux, libv8-3.3.10.4-x86-linux, listen-1.0.2, listen-0.7.3, listen-0.7.2, lumberjack-1.0.3, lumberjack-1.0.2, method_source-0.8.1, multi_json-1.7.2, multi_json-1.5.0, open4-1.3.0, pry-0.9.12.1, pry-0.9.12, pry-0.9.11.4, rack-1.5.2, rack-1.5.0, rack-1.3.5, rake-10.0.4, rake-10.0.3, rake-0.9.2.2, rb-fsevent-0.9.3, rb-inotify-0.9.0, rb-kqueue-0.2.0, ref-1.0.4, ref-1.0.2, rubygems-update-2.0.3, rubygems-update-1.8.25, rubyzip-0.9.9, sass-3.2.8, sass-3.2.7, sass-3.2.5, sassy-buttons-0.1.4, slick-buttons-0.0.6, slop-3.4.4, slop-3.4.3, sprockets-2.9.3, sprockets-2.9.2, sprockets-2.8.2, sprockets-2.0.3, sprockets-helpers-1.0.1, sprockets-helpers-1.0.0, sprockets-helpers-0.8.0, sprockets-sass-1.0.0, sprockets-sass-0.9.1, sprockets-sass-0.3.0, stitch-0.1.6, therubyracer-0.11.4, therubyracer-0.11.3, therubyracer-0.9.9, thor-0.18.1, thor-0.17.0, thor-0.15.4, tilt-1.3.7, tilt-1.3.3, yui-compressor-0.9.6] (Gem::LoadError)
from /usr/lib/ruby/1.9.1/rubygems/dependency.rb:256:in `to_spec'
from /usr/lib/ruby/1.9.1/rubygems.rb:1231:in `gem'
from /usr/local/bin/cap:22:in `<main>'
I'm a noob with Capistrano and Ruby
Any idea to resolve this problem ?
Thx
Probably what's going on is that you installed Capistrano as the root user. However, running capify from a non-root user account is trying to find Capistrano installed for that specific user rather than a system-wide install.
Can you run simply
gem install capistrano railsless-deploy capistrano-ext
As the user, without Sudo?
To answer your comment: It's generally not best practice to be installing and running cap deploy scripts as the root user. For your purposes maybe it will be OK, since you are doing a very limited task with Ruby/Cap; in the future, I would recommend looking into something like RVM.
RVM (Ruby Version Manager) is a tool you will be able to install system-wide, that then will manage your ruby version and gems per user.