create an EC2 using Chef / knife socket error - ruby-on-rails

I am trying to create an EC2 using knife and knife-ec2 gem
command example :
knife ec2 server create --image ami-f7f03d80 -i --flavor t2.micro -x root -i /root/europe.pem —sud —groups chef-client -Z eu-west-1a -r “role[xmpp]”
Error output :
ERROR: Excon::Errors::SocketError: getaddrinfo: Name or service not known (SocketError)
knife.rb :
log_level :info
log_location STDOUT
node_name 'ec2-user'
client_key '/root/.chef/ec2-user.pem'
validation_client_name 'chef-validator'
validation_key '/etc/chef-server/chef-validator.pem'
chef_server_url 'https://ip-****.eu-west-1.compute.internal:443'
syntax_check_cache_path '/root/.chef/syntax_check_cache'
knife[:aws_access_key_id] = '*****'
knife[:aws_secret_access_key] = '*****'
knife[:region] = 'eu-west-1a'
--
gem list knife-ec2
*** LOCAL GEMS ***
knife-ec2 (0.8.0)
Can any one put me on the right direction, i a m suspecting an issue with the ruby gems.
PS :
for some reason knife ec2 flavor list works fine.
Thanks in advance.
regards,
Amine
>
SOLUTION :
fixed by : - reinstalling the ruby gems - reusing the patched version of ec2 create .rb

That error means it's not able to resolve the hostname I believe. I'd start there.

Related

Tiny_tds/freetds workaround needed for Heroku

Is there any way currently to install tiny_tds on a rails 7 app in Heroku on the latest stack? All the workarounds seem to be quite old / inoperable. I am trying to get an Azure MSSQL plugin up and running on Heroku.
I have been able to get the buildpack installed, but every time I use TDS (even making a connection via a heroku rails console), I get a timeout error. If I run the exact same command locally, it works.
client = TinyTds::Client.new host: '<host>.database.windows.net', database: "<database>",username: "<username>#<host>.database.windows.net",password: "<password>", port: 1433, azure: tr
ue, tds_version: 7.4, timeout: 300, login_timeout: 300
Adaptive Server connection timed out ([server].database.windows.net:1433)
Additionally, I can run the following successfully on a heroku bash prompt:
~ $ nslookup
> <host>.database.windows.net
Server: <server ip address>
Address: <server ip address>#53
Non-authoritative answer:
<host>.database.windows.net canonical name = <other host name>.eastus.database.windows.net.
<other host name>.eastus.database.windows.net canonical name = <other host name>.trafficmanager.net.
<other host name>.trafficmanager.net canonical name = <another host name>.control.database.windows.net.
Name: <another host name>.control.database.windows.net
Address: <ip address>
~ $ nc -zv <host>.database.windows.net 1433
Connection to <host>.database.windows.net (<ip address>) 1433 port [tcp/ms-sql-s] succeeded!
I have also tried using freetds on heroku (which is required for tinytds) and get timeouts, so I believe the error traces back to freetds' interaction with heroku or the heroku buildpack, of which I have tried a variety of versions (https://github.com/rails-sqlserver/heroku-buildpack-freetds):
On my local macbook, I can run the freetds tsql connection command to connect almost instantaneously to a variety of mssql databases (one on ec2 and two on azure), but the same command times out on heroku bash prompt:
~ $ tsql -H ***.rds.amazonaws.com -p 1433 -U *** -P ***
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
103Error 20002 (severity 9):
Adaptive Server connection failed
Error 20002 (severity 9):
Adaptive Server connection failed
There was a problem connecting to the server
FreeTDS version local and remote. I did no special "configuration" file settings other than setting the TDS_VERSION to 7.3 when installing the buildpack on heroku.
# LOCAL:
$ tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v1.3.13
freetds.conf directory: /opt/homebrew/etc
MS db-lib source compatibility: no
Sybase binary compatibility: yes
Thread safety: yes
iconv library: yes
TDS version: 7.3
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: yes
OpenSSL: yes
GnuTLS: no
MARS: yes
# Heroku:
$ heroku run bash -a <app>
Running bash on ⬢ <app>... up, run.4557 (Hobby)
~ $ tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v1.3.13
freetds.conf directory: /app/freetds/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 7.3
iODBC: no
unixodbc: no
SSPI "trusted" logins: no
Kerberos: no
OpenSSL: yes
GnuTLS: no
MARS: yes
Any ideas would be greatly appreciated!
This was due to a TLS/openssl compatibility issue. Using gnutls fixes the issue for now.
Some other notes on the issue:
https://github.com/FreeTDS/freetds/issues/336
https://github.com/FreeTDS/freetds/issues/299
If you need to use freetds on heroku-22, see this pull request.
https://github.com/rails-sqlserver/heroku-buildpack-freetds/pull/20
Many thanks to #engineersmnky for some great questions that led to discovering this answer.

Knife bootstrap failing through Jenkins execute shell

I'm trying to perform a "knife bootstrap" command through Jenkins web UI execute shell, but I keep getting this error message :
(this is the knife bootstrap command I'm using) :
"knife bootstrap [the node's IP] --ssh-user ec2-user --sudo --identity-file "[my key to the node]" --node-name My123 --run-list 'role[role1]' "
and this is the error message:
" ERROR: Errno::ENOENT: No such file or directory # rb_sysopen - /etc/chef/validation.pem "
when I run the 'knife bootstrap' command directly through the CLI it works fine.
any idea why it's not working from Jenkins execute shell?
It is due to validation.pem file is missing, this is default path for validation file. Either you can set path in /chef-repo/.chef/knife.rb file or you can use default location /etc/chef/validation.pem.
You can regenerate validation key from webUI and replace the existing one, this should resolve your issue.

Homebrew: Can't start elastic search

I'm in a big trouble, I can't start Elasticsearch and I need it for run my rails locally, please tell me what's going on. I installed Elasticsearch in the normal fashion then I did the following:
elasticsearch --config=/usr/local/opt/elasticsearch/config/elasticsearch.yml
But it shows the following error: [2015-11-01 20:36:50,574][INFO ][bootstrap] es.config is no longer supported. elasticsearch.yml must be placed in the config directory and cannot be renamed.
I tried several alternative ways of run it, like:
elasticsearch -f -D
But then I get the following error, and I can't find any useful for solve it, it seems to be related with file perms but not sure:
java.io.IOException: Resource not found: "org/joda/time/tz/data/ZoneInfoMap" ClassLoader: sun.misc.Launcher$AppClassLoader#33909752
at org.joda.time.tz.ZoneInfoProvider.openResource(ZoneInfoProvider.java:210)
at org.joda.time.tz.ZoneInfoProvider.<init>(ZoneInfoProvider.java:127)
at org.joda.time.tz.ZoneInfoProvider.<init>(ZoneInfoProvider.java:86)
at org.joda.time.DateTimeZone.getDefaultProvider(DateTimeZone.java:514)
at org.joda.time.DateTimeZone.getProvider(DateTimeZone.java:413)
at org.joda.time.DateTimeZone.forID(DateTimeZone.java:216)
at org.joda.time.DateTimeZone.getDefault(DateTimeZone.java:151)
at org.joda.time.chrono.ISOChronology.getInstance(ISOChronology.java:79)
at org.joda.time.DateTimeUtils.getChronology(DateTimeUtils.java:266)
at org.joda.time.format.DateTimeFormatter.selectChronology(DateTimeFormatter.java:968)
at org.joda.time.format.DateTimeFormatter.printTo(DateTimeFormatter.java:672)
at org.joda.time.format.DateTimeFormatter.printTo(DateTimeFormatter.java:560)
at org.joda.time.format.DateTimeFormatter.print(DateTimeFormatter.java:644)
at org.elasticsearch.Build.<clinit>(Build.java:51)
at org.elasticsearch.node.Node.<init>(Node.java:135)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
[2015-11-01 20:40:57,602][INFO ][node ] [Centurius] version[2.0.0], pid[22063], build[de54438/2015-10-22T08:09:48Z]
[2015-11-01 20:40:57,605][INFO ][node ] [Centurius] initializing ...
Exception in thread "main" java.lang.IllegalStateException: failed to load bundle [] due to jar hell
Likely root cause: java.security.AccessControlException: access denied ("java.io.FilePermission" "/usr/local/Cellar/elasticsearch/2.0.0/libexec/antlr-runtime-3.5.jar" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
at java.security.AccessController.checkPermission(AccessController.java:884)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
at java.util.zip.ZipFile.<init>(ZipFile.java:210)
at java.util.zip.ZipFile.<init>(ZipFile.java:149)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:103)
at org.elasticsearch.bootstrap.JarHell.checkJarHell(JarHell.java:173)
at org.elasticsearch.plugins.PluginsService.loadBundles(PluginsService.java:340)
at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:113)
at org.elasticsearch.node.Node.<init>(Node.java:144)
at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:145)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.
Thanks for your help.
There are some changes with libexec with Elasticsearch/homebrew installation and that is why it is failing to start. There is a PR #45644 currently being worked on. Till the PR gets accepted, you can use the same formula to fix the installation of Elasticsearch.
First uninstall the earlier/older version. Then edit the formula of Elasticsearch:
$ brew edit elasticsearch
And use the formula from the PR.
Then do brew install elasticsearch, it should work fine.
To start Elasticsearch, just do:
$ elasticsearch
config option is no longer valid. For custom config, use path.config:
$ elasticsearch --path.conf=/usr/local/opt/elasticsearch/config

capistrano-resque error with remote Redis DB

Hey I'm configuring my capistrano-resque, and I have a remote redis DB.
This is how my capistrano-resque configuration looks in deploy.rb:
set :resque_environment_task, true
role :resque_worker, ENV['REDIS_SERVER']
role :resque_scheduler, ENV['REDIS_SERVER']
set :workers, { "*" => 1 }
When I try to run cap production git:check, deploy:check I get the following error:
INFO [1df5c9be] Running /usr/bin/env mkdir -p /tmp/mk/ as deploy#ipaddress
INFO [b91cbf1f] Running /usr/bin/env mkdir -p /tmp/mk/ as redis#//x
DEBUG [1df5c9be] Command: /usr/bin/env mkdir -p /tmp/mk/
DEBUG [b91cbf1f] Command: /usr/bin/env mkdir -p /tmp/mk/
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as redis#//x: getaddrinfo: nodename nor servname provided, or not known
SocketError: getaddrinfo: nodename nor servname provided, or not known
It seems like there is something with redis#//x ? I have the full connection string stored as a local env both locally and in production:
redis://x:[password]#aws-eu-west.0.dblayer.com:10156
Anybody have an idea on what's wrong?
The problem is that you're supplying a Redis address instead of an SSH address. Capistrano uses SSHKit to execute remote SSH commands on the server -- whatever you set as the role will be the server it uses. The role :resque_worker line isn't anything fancy we added in capistrano-resque, it's just assigning another role for Capistrano/SSHKit to use (in addition to the default app/web/db roles Capistrano includes by default).
In other words, the :resque_worker setting isn't to specify which Redis server contains your job queue, it's to specify which server to run commands like rake resque:work on.
So in a single-server scenario, your :resque_worker role should probably be the same as your role :app ... line, for example:
role :app, "me#example.com"
role :resque_worker, "me#example.com"
Doing so would connect via SSH to to the me account at example.com and execute the commands.
See http://capistranorb.com/documentation/getting-started/preparing-your-application/ (Section 4) for more info on how roles are defined/used.

Gitlab API Access Connection timed out

I just installed Gitlab and I have an error during the gitlab-shell self check.
The command returns :
root#git:/home/git/gitlab# sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
Checking Environment ...
Git configured for git user? ... yes
Checking Environment ... Finished
Checking GitLab Shell ...
GitLab Shell version >= 1.9.3 ? ... OK (1.9.3)
Repo base directory exists? ... yes
Repo base directory is a symlink? ... no
Repo base owned by git:git? ... yes
Repo base access is drwxrws---? ... yes
Satellites access is drwxr-x---? ... yes
update hook up-to-date? ... yes
update hooks in repos are links: ...
Thibaud / thibaud-dauce ... repository is empty
Running /home/git/gitlab-shell/bin/check
Check GitLab API access: /usr/local/lib/ruby/2.0.0/net/http.rb:878:in `initialize': Connection timed out - connect(2) (Errno::ETIMEDOUT)
from /usr/local/lib/ruby/2.0.0/net/http.rb:878:in `open'
from /usr/local/lib/ruby/2.0.0/net/http.rb:878:in `block in connect'
from /usr/local/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
from /usr/local/lib/ruby/2.0.0/net/http.rb:877:in `connect'
from /usr/local/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
from /usr/local/lib/ruby/2.0.0/net/http.rb:851:in `start'
from /home/git/gitlab-shell/lib/gitlab_net.rb:76:in `get'
from /home/git/gitlab-shell/lib/gitlab_net.rb:43:in `check'
from /home/git/gitlab-shell/bin/check:11:in `<main>'
gitlab-shell self-check failed
Try fixing it:
Make sure GitLab is running;
Check the gitlab-shell configuration file:
sudo -u git -H editor /home/git/gitlab-shell/config.yml
Please fix the error above and rerun the checks.
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
Database config exists? ... yes
Database is SQLite ... no
All migrations up? ... yes
Database contains orphaned UsersGroups? ... no
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Init script exists? ... yes
Init script up-to-date? ... yes
projects have namespace: ...
Thibaud / thibaud-dauce ... yes
Projects have satellites? ...
Thibaud / thibaud-dauce ... can't create, repository is empty
Redis version >= 2.0.0? ... yes
Your git bin path is "/usr/bin/git"
Git version >= 1.7.10 ? ... yes (1.7.10)
Checking GitLab ... Finished
Of course, Gitlab is running :
root#git:/home/git/gitlab# service gitlab status
The GitLab Unicorn web server with pid 1543 is running.
The GitLab Sidekiq job dispatcher with pid 1736 is running.
GitLab and all its components are up and running.
And my config file :
root#git:/home/git/gitlab# sudo -u git -H cat /home/git/gitlab-shell/config.yml
# GitLab user. git by default
user: git
# Url to gitlab instance. Used for api calls. Should end with a slash.
gitlab_url: "http://git.thibaud-dauce.fr/"
http_settings:
# user: someone
# password: somepass
# ca_file: /etc/ssl/cert.pem
# ca_path: /etc/pki/tls/certs
self_signed_cert: false
# Repositories path
# Give the canonicalized absolute pathname,
# REPOS_PATH MUST NOT CONTAIN ANY SYMLINK!!!
# Check twice that none of the components is a symlink, including "/home".
repos_path: "/home/git/repositories"
# File used as authorized_keys for gitlab user
auth_file: "/home/git/.ssh/authorized_keys"
# Redis settings used for pushing commit notices to gitlab
redis:
bin: /usr/bin/redis-cli
host: 89.234.146.59
port: 6379
# socket: /tmp/redis.socket # Only define this if you want to use sockets
namespace: resque:gitlab
# Log file.
# Default is gitlab-shell.log in the root directory.
# log_file: "/home/git/gitlab-shell/gitlab-shell.log"
# Log level. INFO by default
log_level: INFO
# Audit usernames.
# Set to true to see real usernames in the logs instead of key ids, which is easier to follow, but
# incurs an extra API call on every gitlab-shell command.
audit_usernames: false
I already try to replace in Redis conf host: 127.0.0.1 to host: 89.234.146.59
I also try to add 89.234.146.59 git.thibaud-dauce.fr in /etc/hosts
I have a server running Debian 7 32bits with a container LXC for Gitlab, Ruby is version 2.0.0. I have the same error when I try to push a repo (but I can create one online with the web app)
Do you have any idea ? I really look everywhere and found no solution...

Resources