[Semibug] Ansible vs FreeBSD
Mark Moellering
markmoellering at psyberation.com
Thu Apr 25 11:09:17 EDT 2019
Mike,
I am a little sick but your problems reminded me of some issues I had
when trying to use pgadmin4, which also uses some sort of python virtual
environment.
This is an email I tried to send to the freebsd group but ran into some
strange issue. anyway, it details getting pgadmin4 running in the
python environment and I thought it might help.
Again, I have been sick, so I apologize if this is irrelevant
Mark Moellering <markmoellering at psyberation.com>
Sat, Feb 9, 2:02 PM
to freebsd-questions
Having just done this, I wanted to post this here, in case this will
help others.
This is based off of a Computing For Geeks article by Josphat Mutai, but
I felt there were a couple of pieces missing.
I installed this on my local development machine, "hal" in the examples,
not the postgresql server but I don't think that should change much
beyond the connection definitions once pgadmin4 is up and running.
(original article)
https://computingforgeeks.com/how-to-install-pgadmin4-on-freebsd-12/
<https://computingforgeeks.com/how-to-install-pgadmin4-on-freebsd-12/>
pgadmin4 can use python 2.7 or 3.6 As python 2.7 has an end of life of
Jan, 1 2020, I opted for python 3.6
Pre-Installation Setup
install python36 -- pkg install python36
install python pip package manager -- pkg install py36-pip
install python virtualenvironment -- pkg install py36-virtualenv
Installing pgAdmin4
As Root, go to /usr/local
start a python virtual environment for pgadmin4:
root at hal:/usr/local # virtualenv-3.6 pgadmin4
Then run:
source pgadmin4/bin/activate
This did not work for me, so I had to use:
root at hal:/usr/local # source pgadmin4/bin/activate.csh
Next, load the python dependancies through pip:
[pgadmin4] root at hal:/usr/local #pip install pyopenssl cryptography
pyasn1 ndg-httpsclient
Then, load sqlite3:
[pgadmin4] root at hal:/usr/local #pkg install py36-sqlite3
Finally, install pgAdmin4 using pip. Make sure to check for the latest
version and directory:
[pgadmin4] root at hal:/usr/local #pip install
https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.2/pip/pgadmin4-4.2-py2.py3-none-any.whl
<https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.2/pip/pgadmin4-4.2-py2.py3-none-any.whl>
(On my 8-core Ryzen, this took less than a minute.)
Configuration and running
To exit the python virtual environment, run:
#deactivate.
I exited the virtual environment at this point, but I don't think it is
necessary.
next, in the directory:
root at hal:/usr/local/pgadmin4/lib/python3.6/site-packages/pgadmin4
run:
cp config.py to config_local.py
- and edit the config_local.py file
around line 140, it will have;
DEFAULT_SERVER = '127.0.0.1'
THIS WILL NOT WORK. You must change it to;
DEFAULT_SERVER = '0.0.0.0' (or a static IP, if you have one)
To run pgAdmin4, you must be in the python virtual environment, and then
run the pgAdmin4.py script;
root at hal:/usr/local # virtualenv-3.6 pgadmin4
root at hal:/usr/local # source pgadmin4/bin/activate.csh
[pgadmin4] root at hal:/usr/local # python ./pgadmin4/lib/python3.6/site-
packages/pgadmin4/pgAdmin4.py
It will ask for an email address and password the first time you run it,
as displayed below;
NOTE: Configuring authentication for SERVER mode.
Enter the email address and password to use for the initial pgAdmin user
account:
Email address: markmoellering at psyberation.com
<mailto:markmoellering at psyberation.com>
Password:
Retype password:
pgAdmin 4 - Application Initialisation
======================================
Starting pgAdmin 4. Please navigate to http://0.0.0.0:5050 in your browser.
And it should work (it did for me at any rate).
I went http://127.0.0.1:5050 and was able to log in and attach to my
remote server. When I initially left the DEFAULT_SERVER = '127.0.0.1',
I could login but then the web-stie would crash. I changed the setting
to 0.0.0.0 and then http://127.0.0.1:5050 worked as expected. I haven't
written an rc script for it yet but I may in the future.
I hope this helps someone. While the original instructions by Josphat
Mutai were quite good, there were just a couple of gotchas that I
thought should be explained in more detail
On 4/24/19 4:31 PM, Mike Wayne wrote:
> Trying to set up a new machine with Ansible. I think I'm
> missing something:
> Doing anything in a virtual python environment like:
> https://serversforhackers.com/c/an-ansible2-tutorial
> fails utterly.
>
> By running it globally, I can get a little further but even
> a simple package install fails:
>
> $ cat freebsdpkg.yml:
> - hosts: jails
> tasks:
> - name: Add packages on FreeBSD
> pkgng:
> name: wget
>
> TASK [Add packages on FreeBSD] ********************************************************************************************************************************************************
> fatal: [192.186.3.145]: FAILED! => {"changed": false, "msg": "Could not update catalogue"}
>
>
> Is Ansible simply not ready for prime time?
>
> _______________________________________________
> Semibug mailing list
> Semibug at lists.nycbug.org
> http://lists.nycbug.org:8080/mailman/listinfo/semibug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nycbug.org:8080/pipermail/semibug/attachments/20190425/826078be/attachment.html>
More information about the Semibug
mailing list