Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

offline role installation is not possible or documented #2030

Closed
ssbarnea opened this issue Sep 27, 2019 · 7 comments
Closed

offline role installation is not possible or documented #2030

ssbarnea opened this issue Sep 27, 2019 · 7 comments

Comments

@ssbarnea
Copy link
Member

ssbarnea commented Sep 27, 2019

Initially raised as a question, but it seems to be more of a bug as the documentation does not state any way of installing a role from a local source.

Documentation of requirements.yml is very well hidden at https://docs.ansible.com/ansible/latest/reference_appendices/galaxy.html#installing-multiple-roles-from-a-file and does not give any example of using a local source, like a file:// url or something similar.

There are multiple reasons for needing this:

  • environments where internet access is blocked
  • GitHub giving 401 Access Denied
  • CI testing, where installing roles could be done a big number of times even inside the same job.
---
- name: timezone
  src: yatesr.timezone
  version: 1.1.0

This bus is also a blocker for changing default dependency installer in molecule from gilt to galaxy, because gilt works offline.

Update

The current specification of requirements.yml allows installing roles from localhost but only from full paths by using the undocumented file:/// scheme as src.

Still this makes installation fully not portable, mainly impossible to install roles from current user directory. The file:// scheme does not allow by design relative paths due to security concerns with browser use.

Also there is no expansion of current user home directory, or even CWD, both of them being needed in order to be able to implement a portable offline installation.

When no uri prefix is given, galaxy assumes that the roles are from galaxy. Maybe we can sort this issue by looking if string starts with ./ or ~ and assume is a local file path. I guess this should not conflict with galaxy role naming conventions.

This caused ansible/molecule#2334 where on molecule we are forced to disable any testing of galaxy-install because testing it does trigger GitHub DDOS protection mechanisms and instead of downloading the very small test role we get HTTP 500 errors.

STEPS TO REPRODUCE
# requirements.yml                                                                                                                                                     - name: foo
  src: ./reqs.txt  # <-- try to put something here that points to something relative to CWD
EXPECTED RESULTS

I would expect to allow users to install roles from disk using paths relative to home-dir, cwd or maybe even using jinja2 expansions (so we can lookup env).

ssbarnea added a commit to ssbarnea/molecule that referenced this issue Sep 27, 2019
Workaround-For: ansible/galaxy#2030
Fixes: ansible#2334
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
ssbarnea added a commit to ssbarnea/molecule that referenced this issue Sep 27, 2019
Workaround-For: ansible/galaxy#2030
Fixes: ansible#2334
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
ssbarnea added a commit to ansible/molecule that referenced this issue Sep 27, 2019
Workaround-For: ansible/galaxy#2030
Fixes: #2334
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
@chouseknecht
Copy link
Contributor

You can simply pass in a list of tar files. Here's the instructions from ansible-galaxy install --help:

Usage: ansible-galaxy install [options] [-r FILE | role_name(s)[,version] | scm+role_repo_url[,version] | tar_file(s)]

Install Roles from file(s), URL(s) or tar file(s)

Options:
  -f, --force           Force overwriting an existing role
  -h, --help            show this help message and exit
  -c, --ignore-certs    Ignore SSL certificate validation errors.
  -i, --ignore-errors   Ignore errors and continue with the next specified
                        role.
  -g, --keep-scm-meta   Use tar instead of the scm archive option when
                        packaging the role
  -n, --no-deps         Don't download roles listed as dependencies
  -r ROLE_FILE, --role-file=ROLE_FILE
                        A file containing a list of roles to be imported
  -p ROLES_PATH, --roles-path=ROLES_PATH
                        The path to the directory containing your roles. The
                        default is the roles_path configured in your
                        ansible.cfg file (/etc/ansible/roles if not
                        configured)
  -s API_SERVER, --server=API_SERVER
                        The API server destination
  -v, --verbose         verbose mode (-vvv for more, -vvvv to enable
                        connection debugging)
  --version             show program's version number and exit

If you feel more examples in the docs would be helpful, please submit a PR to the Ansible project.

@ssbarnea
Copy link
Member Author

@chouseknecht Maybe I was not clear that we are using requirements.yml files for testing and is impossible to switch to CLI on molecule, it would invalidate the entire idea of having requirements.yml files.

I also updated the description, this bug needs to be reopen.

@ssbarnea
Copy link
Member Author

Another issue is that apparently galaxy-install returns error if no roles are mentioned inside the requirements.yml file, this also closing another door related to testing.

@decentral1se
Copy link

Should be re-opened, please re-read @chouseknecht.

@chouseknecht
Copy link
Contributor

@decentral1se @ssbarnea

This issue needs to be opened at the Ansible project, as the ansible-galaxy command line tool is part of Ansible.

@decentral1se
Copy link

🤦‍♂️

ssbarnea added a commit to ssbarnea/ansible that referenced this issue Jul 28, 2020
Fix bug where ansible-galaxy install would fail when given
paths starting with tilde (user home).

Related: ansible/galaxy#2030
ssbarnea added a commit to ssbarnea/ansible that referenced this issue Jul 28, 2020
Fix bug where ansible-galaxy install would fail when given
paths starting with tilde (user home).

Related: ansible/galaxy#2030
ssbarnea added a commit to ssbarnea/ansible that referenced this issue Jul 28, 2020
Fix bug where ansible-galaxy install would fail when given
paths starting with tilde (user home).

Related: ansible/galaxy#2030
ssbarnea added a commit to ssbarnea/ansible that referenced this issue Jul 28, 2020
Fix bug where ansible-galaxy install would fail when given
paths starting with tilde (user home).

Related: ansible/galaxy#2030
ssbarnea added a commit to ssbarnea/ansible that referenced this issue Nov 3, 2020
Fix bug where ansible-galaxy install would fail when given
paths starting with tilde (user home).

Related: ansible/galaxy#2030
@KasperSkytte
Copy link

KasperSkytte commented May 30, 2022

When creating new ansible galaxy roles with a ansible-galaxy init I also got annoyed that I would have to commit and push changes to a git repo first to be able to install from there and test out the changes. Now I simply make a symbolic link from the folder with the role in development to a folder in roles/ and use that instead. Surely it would be more handy to have a development feature to complement ansible-galaxy init to install with something like ansigle-galaxy install path/to/new/role --type local.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants