ansible-galaxy failing for init install - Failed to get data from the API server - a bytes-like object is required, not 'str' - ansible-2.x

ansible: ansible-galaxy 2.2.0.0
python: Python 2.7.10
I tried ansible-galaxy command to create a new role structure (init command) but it failed with the following message. So, I looked online and tried --offline option and structure creation part worked.
So far, I have my Github repo: https://github.com/asangal/wavefront-ansible
Role is also visible in Ansible Galaxy under Browse Roles.
https://galaxy.ansible.com/list#/roles?page=1&page_size=10&autocomplete=wavefront or
https://galaxy.ansible.com/asangal/wavefront-ansible/
As per the instructions, I'm trying to run the install step by running
but it failed again with the same error message as shown below.
$ ansible-galaxy install asangal.wavefront-ansible
[WARNING]: - asangal.wavefront-ansible was NOT installed successfully: Failed to get data from the API server (https://galaxy.ansible.com/api/): a bytes-like object is
required, not 'str'
ERROR! - you can use --ignore-errors to skip failed roles and finish processing the list.
OR (used --ignore-errors and -p <role_path> options but it didn't help)
$ ansible-galaxy install asangal.wavefront-ansible --ignore-errors -p ~/aks/dummy
[WARNING]: - asangal.wavefront-ansible was NOT installed successfully: Failed to get data from the API server (https://galaxy.ansible.com/api/): a bytes-like object is
required, not 'str'
[arun#vagrant ~/aks/dummy] $ ls -l
[arun#vagrant ~/aks/dummy] $
curl -v https://galaxy.ansible.com/asangal/wavefront-ansible/ seems to work fine.
Why am I getting this error: Failed to get data from the API server (https://galaxy.ansible.com/api/): a bytes-like object is
required, not 'str'?

Your role downloads fine for me with Python 2.7.13.
The bytes-like object is required, not 'str' is Python3 related, i suspect you should be ok if you use Python 2.x.

So, thanks to Zlemini. So to clarify:
My ansible is actually was coming from Python 3.5 path. Even though default python was 2.7.10.
[arun#host ~/aks/dummy] $ python --version
Python 2.7.10
[arun#host ~/aks/dummy] $ python3 --version
Python 3.5.2
[arun#host ~/aks/dummy] $
[arun#host ~/aks/dummy] $ which ansible-galaxy
/Library/Frameworks/Python.framework/Versions/3.5/bin/ansible-galaxy
[arun#host ~/aks/dummy] $
[arun#host ~/aks/dummy] $ which ansible
/Library/Frameworks/Python.framework/Versions/3.5/bin/ansible
Running the same install command it from my other vagrant machine where, ansible was actually coming from /usr/bin/ansible, the command worked as expected.
$ ansible-galaxy install asangal.wavefront-ansible -p ~/aks/dummy
- downloading role 'wavefront-ansible', owned by asangal
- downloading role from https://github.com/asangal/wavefront-ansible/archive/master.tar.gz
- extracting asangal.wavefront-ansible to /home/vagrant/dummy/asangal.wavefront-ansible
- asangal.wavefront-ansible was installed successfully
[vagrant#myvagrant ~/aks/dummy] $ ls -l
total 4
drwxrwxr-x. 9 vagrant vagrant 4096 Jan 24 23:16 asangal.wavefront-ansible

Related

opam init fails to verify certificate

On a completely fresh ubuntu 18.04 VM I tried to install opam:
$ wget https://github.com/ocaml/opam/releases/download/2.1.0/opam-2.1.0-x86_64-linux
$ mv opam-2.1.0-x86_64-linux opam
$ chmod 777 opam
$ ./opam init
And here is the error I got
<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[ERROR] Could not update repository "default": OpamDownload.Download_fail(_,
"Download command failed: \"/usr/bin/wget --content-disposition -t 3 -O
/tmp/opam-5936-f23d09/index.tar.gz.part -U opam/2.1.0 --
https://opam.ocaml.org/index.tar.gz\" exited with code 5 \"ERROR:
cannot verify opam.ocaml.org's certificate, issued by
\226\128\152CN=Zscaler Intermediate Root CA (zscaler.net) (t)\\\\
,OU=Zscaler Inc.,O=Zscaler Inc.,ST=California,C=US\226\128\153:\"")
[ERROR] Initial download of repository failed.
How should I solve this?
I ran into the same issue and I found a workaround on the OCaml forum: here. (Credits to UnixJunkie)
You can run:
opam init github git+https://github.com/ocaml/opam-repository.git
This should avoid the certificate issues. This worked for me.
I tried to fix the certificate issues using this answer as well. You could try doing that, but it seems complicated when the workaround is to simply point it to the github repo directly.
Update
The reason opam init failed for me was because curl was installed with snap on my system.
Try to run opam init -verbose and that could reveal more about why you ran into an error.
In my case I needed to install other things with opam and it kept failing every time. So snap uninstall curl and then sudo apt install curl fixed things. (Was only able to figure this out with the help from my professor)

Zsh: Command Not found : mongo After trying to install mongodb 4.2 using brew

I have tried the following steps to install and setup mongodb in my mac from here https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/ but I got the following error when running the final "mongo" command in my terminal:
Error Message - Zsh: Command Not found : mongo
This error msg occurred after trying to install mongodb 4.2 using brew
sudo chown -R $(whoami) $(brew --prefix)/*
then
brew tap mongodb/brew
then
brew install mongodb-community#4.2
and
brew services start mongodb-community#4.2
or
mongod --config /usr/local/etc/mongod.conf
then
ps aux | grep -v grep | grep mongod
and
mongo
running brew services start mongodb-community#4.2 returns:
Successfully started `mongodb-community#4.2` (label: homebrew.mxcl.mongodb-community#4.2)
running ps aux | grep -v grep | grep mongod returns:
9081 0.2 0.5 5528024 41856 ?? S 3:01pm 0:01.48 /usr/local/opt/mongodb-community#4.2/bin/mongod --config /usr/local/etc/mongod.conf
7613 0.0 0.1 4298832 5600 s000 T 2:47pm 0:00.08 vim /usr/local/etc/mongod.conf
running mongod --config /usr/local/etc/mongod.conf returns:
zsh: command not found: mongod
There are also no mongo files in my /usr/local/bin directory after using these commands
I created a data/db folder in my /usr/local/bin directory using the following commands:
sudo mkdir -p /usr/local/bin/data/db
sudo chown -R `id -un` /usr/local/bin/data/db
Running "brew update" returns:
brew update
Updated 1 tap (homebrew/cask).
==> Updated Casks
brave-browser
brew install mongodb-community-shell
Fixed the problem for me.
Solved it by manually installing the mongodb community files and db tools using the website instead. Then copying them into /usr/local/bin. Then ignoring the app permissions whenever calling mongo or related commands in the terminal through System Preferences > Security & Privacy > General.
After googling I found out that mongoimport and the other features have to be installed separately: https://www.mongodb.com/try/download/database-tools
Followed by copying those bin files after extracting them into the same /usr/local/bin directory
Not sure why its' not working through homebrew though
This worked for me, I was having same issue on mongodb-community#4.4
brew reinstall mongodb-community#4.4
On terminal something like this will appear during reinstallation.
copy highlighted path with echo
echo 'export PATH="/opt/homebrew/opt/mongodb-community#4.4/bin:$PATH"' >> ~/.zshrc
Now open another terminal and start mongodb services
brew services restart mongodb/brew/mongodb-community#4.4
write mongo on terminal and here we fly
If you installed the mongodb via Homebrew. Need to add the mongo path in your bash_profile.
Edit the bash_profile vi ~/.bash_profile
Add the below line in EOF export PATH=$PATH:/usr/local/opt/mongodb-community#4.2/bin
After the edit bash_profile. Close all terminals and open them again. mongo command start works.
In addition to #ramesh-babu-t-b 's answer, https://stackoverflow.com/a/68407530/1279516, the issue could also be that your MongoDB installation did add mongod to your path, but the installation happened within the current shell session, and so your shell doesn't have the updates to the PATH variable yet.
In this case, only his last step is still necessary - Open a new console window and retry the mongod command.

Installing Dropbox on Ubuntu 18 Server Failing

I am following this article to install and tried both methods.
Downloading the headless and the .deb methods I run the following commands:
$ ./dropboxd
And the DEB:
$ sudo dpkg -i dropbox_2020.03.04.deb
$ sudo apt -f install
$ dropbox start
For both I'm getting the error:
ImportError: libglapi.so.0:
I'm new to Linux server and I'm a little bit lost. Should I upgrade my server to Ubuntu 20?

MongoDB Catalina: connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017

I just updated my mac to Catalina 10.15.2 and I can't running MongoDB.
When I send the command mongo I receive this message
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
and the only way to make Mongo work is to restart the Mac.
If I check the process with the command ps I don't see the process already on and the port 27017 is available.
I already tried to run the follow command:
brew tap mongodb/brew
brew reinstall mongodb-community
brew services restart mongodb-community
and if I run the follow command:
ps aux | grep -v grep | grep mongod
no results.
I tried to run mongod before mongo as well and the result is:
2019-12-18T12:17:45.916+0100 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-12-18T12:17:45.920+0100 I CONTROL [initandlisten] MongoDB starting : pid=9375 port=27017 dbpath=/data/db 64-bit host=Marcos-MacBook-Pro.local
2019-12-18T12:17:45.920+0100 I CONTROL [initandlisten] db version v4.2.1
2019-12-18T12:17:45.920+0100 I CONTROL [initandlisten] git version: edf6d45851c0b9ee15548f0f847df141764a317e
2019-12-18T12:17:45.920+0100 I CONTROL [initandlisten] allocator: system
2019-12-18T12:17:45.920+0100 I CONTROL [initandlisten] modules: none
2019-12-18T12:17:45.920+0100 I CONTROL [initandlisten] build environment:
2019-12-18T12:17:45.920+0100 I CONTROL [initandlisten] distarch: x86_64
2019-12-18T12:17:45.920+0100 I CONTROL [initandlisten] target_arch: x86_64
2019-12-18T12:17:45.920+0100 I CONTROL [initandlisten] options: {}
2019-12-18T12:17:45.920+0100 E NETWORK [initandlisten] Failed to unlink socket file /tmp/mongodb-27017.sock Permission denied
2019-12-18T12:17:45.920+0100 F - [initandlisten] Fatal Assertion 40486 at src/mongo/transport/transport_layer_asio.cpp 693
2019-12-18T12:17:45.920+0100 F - [initandlisten]
***aborting after fassert() failure
Someone can help me please? I appreciate it
An alternative way to fix this Catalina Mac OS root & mongodb connection issue, do the following:
Install Homebrew, if you have it, reinstall it again
run the following commands in the terminal
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew untap mongodb/brew && brew tap mongodb/brew
brew install mongodb-community#4.2
The issue is mongo cannot find /db/data because there is no directory, so you have to create one:
cd ~ (this should take you to your Users folder)
from the Users folder make your own db/data folder by running the follow commands:
mkdir db & cd inside db folder
inside the db folder run: mkdir data & cd inside data folder
run this command: mongod --dbpath ~/data/db
(inside the Users/data/db/ folder you just created)
Now open a new terminal tab &
run: cd ~ (brings you back to Users) -> now run : cd .. & cd .. again (do this twice)
(now you should be in the folder before Users)
(now find tmp folder) cd into the /tmp folder
delete the sock file (this is giving you connection issues)
delete it by running: rm -rf mongodb-27017.sock
now run command: mongo (this should work now)
inside mongo shell run command: db.verion()
if you see a version, your connection works.
From now on to run mongodb database & connection you will have to have two separate tabs open at all times whenever you want to work on your projects
Example:
in one terminal tab run command -> mongod --dbpath ~/data/db
(this starts the connection)
in the other terminal tab run command: mongo
(this starts the shell)
These both have to be running..
Side Note:
you no longer need to start
the connection by running
brew services start mongo-community anymore.
remember mongod --dbpath ~/data/db is basically -> mongod command now.. The Mac OS Catalina Update created root permission problems, that is why mongod command alone never worked before.
Hope this helped you. Goodluck.
Faced a similar issue with macOS Big Sur. After trying all the approaches mentioned above including
updating homebrew
reinstalling MongoDB, MongoDB community and setting up a /System/Volumes/Data/data/dbfolder
This command worked for me mongod --dbpath=/System/Volumes/Data/data/db
reference: https://medium.com/codespace69/mongodb-troubleshooting-errors-for-beginners-and-macos-catalina-31befd99f6c8
This error is caused due to ownership issues.
Here we are changing the ownership to 'mongodb' user.
Command 1: deletes the /tmp/mongodb-27017.sock file
$sudo rm -rf /tmp/mongodb-27017.sock
Command 2: starts mongod service
$sudo service mongod start
Command 3: shows the file with its ownership details
ls -lsah /tmp/mongodb-27017.sock
output
0 srwx------ 1 mongodb mongodb 0 Aug 24 04:01 /tmp/mongodb-27017.sock
Got the same issue after upgrading to Catalina. Tried lots of ways to solve the issue, what eventually helped was reinstalling brew, and then following steps listed on official mongodb site.
So:
Uninstall brew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)
Install it again:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
Follow steps to install and run monbo service:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

Uninstall MongoDB on Mac OS X

When I try to run mongod from the terminal, I get the following error:
2014-07-02T23:56:24.797-0700 [initandlisten] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:27017
2014-07-02T23:56:24.797-0700 [initandlisten] ERROR: addr already in use
I recently realize that I have two versions of MongoDB on my Mac, and think this may be the source for the above error. (Plus, I do not need two version.) I tried Googling, but was not able to find clear directions on how I can uninstall. I have development version 2.7.0 AND 2.6.3.
Thanks so much in advance for the help!
Run the following commands to remove mongodb from the launch/startup and to uninstall it using Homebrew:
# See if mongo is in the launch/startup list
launchctl list | grep mongo
# Remove mongodb from the launch/startup
launchctl remove homebrew.mxcl.mongodb
# Kill the mongod process just in case it's running
pkill -f mongod
# Now you can safely remove mongodb using Homebrew
brew uninstall mongodb
Just double-check in /usr/local/bin/ to make sure that the mongodb commands are removed.
For uninstalling the community version, i found that the command brew uninstall mongodb-community worked for me
Nitin Jadhav version worked for me, brew uninstall mongodb kept given me Error: No such keg: /usr/local/Cellar/mongodb. I was removing a mongodb-community.
use cd /usr/local/Cellar then run ls -a and then run rm -rf mongodb-community to remove it
I would suggest navigating into your /usr/local/Cellar and run an ls -a, I had a community version of mongo installed that wasn't being picked up by the command given above. If you find any mongo versions there just rm -rf each instance
For those having this error in osx:
brew uninstall mongodb Error: No such keg: /usr/local/Cellar/mongodb
execute brew list | grep mongo
for example, it could show something like:
mongodb-community#4.2
mongodb-database-tools
mongosh
remove them with brew uninstall mongodb-community#4.2 mongodb-database-tools mongosh
Also execute launchctl remove homebrew.mxcl.mongodb as #anuvrat-tiku says in his answer.

Resources