Bug 1465966 - [RFE][S-3] Allow use of local file system repos for Ansible playbooks
Summary: [RFE][S-3] Allow use of local file system repos for Ansible playbooks
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Providers
Version: 5.8.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: MVP
: 5.10.0
Assignee: Loic Avenel
QA Contact: Satyajit Bulage
URL:
Whiteboard:
Depends On:
Blocks: 1498997 1597396
TreeView+ depends on / blocked
 
Reported: 2017-06-28 14:28 UTC by jritenou
Modified: 2019-02-11 13:54 UTC (History)
17 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-02-11 13:54:19 UTC
Category: ---
Cloudforms Team: Ansible
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description jritenou 2017-06-28 14:28:16 UTC
Description of problem: Working with public sector clients, I am often asked to stand up CloudForms in a disconnected environment with no internet access for proof of concepts.  Oftentimes, these environments have no internal git infrastructure in place.  As we start to plan out POCs based on CloudForms 4.5, I've begun thinking how I will handle importing Ansible playbooks for proving out functionality of embedded Ansible.

I see that there is a URL validator rule in place (opt/rh/cfme-gemset/bundler/gems/manageiq-ui-classic-1048ffdbd63f/app/views/ansible_repository/_repository_form.html.haml) which only allows HTTP or HTTPS git repos to be added.  As an addendum to https://bugzilla.redhat.com/show_bug.cgi?id=1452584, I'd ask that we able to add local file system git repos as well, so we can simply copy playbooks to the appliance with the Ansible role and initialize the directory. 


Version-Release number of selected component (if applicable): 5.8.x


How reproducible: Always


Steps to Reproduce:
1. Try add an Ansible repository prefixed with file:///
2. Message will display indicating repos must be http or https:

Actual results: Can not add local file system repo


Expected results: Would like to have to the option to use local file system for playbooks as the backend supports it.


Additional info: I removed the validator rule in a test env (line 55 of the indicated file), and was able to create local file system repos. Functions as expected without the url-validator in place.

Comment 2 James Wong 2017-06-29 14:18:42 UTC
This is a RFE. I am assigning to John to decide on
1. if we want to support this
2. and assign a PM score for priority assessment.

regards,
James

Comment 8 Sudhir Mallamprabhakara 2018-06-14 14:52:20 UTC
Pavol,

Can you please test this against upstream 5.10 build?

- Sudhir

Comment 11 Jason Frey 2018-07-02 21:13:17 UTC
Pavol...it seems there was a miscommunication and we didn't give the steps on what we expected you to test.  We know it doesn't work through the UI, but since this is for POC/demo purposes, it doesn't *have* to work through the UI.  That is, someone will be SSHing or SCPing into the appliance anyway, so we can give a tool or set of steps to make it work.  There are 2 approaches, if you could test them out:


1) Reusing an existing content/ansible directory to leverage built-in EmbeddedAnsible seeding.

    a) Copying the playbooks into an existing /content/ansible directory, (I think /opt/rh/cfme-gemset/gems/manageiq-content-*/content/ansible should work)
    b) Enable Embedded Ansible role and let it seed

  Doing it this way would make the playbooks appear like they came with CloudForms which may or may not be acceptable.  We could also tweak the code to allow /var/www/miq/vmdb/content/ansible if it would make things easier.

2) Creating a new "repo" in EmbeddedAnsible

    a) Enable Embedded Ansible role
    b) Put the content anywhere on the appliance
    c) Add repo content to Embedded Ansible

      git init -q
      git add .

      GIT_COMMITTER_NAME="System" GIT_COMMITTER_EMAIL="system@localhost" \
      GIT_AUTHOR_NAME="System" GIT_AUTHOR_EMAIL="system@localhost" \
      git commit -q -m"Initial Commit"

      vmdb
      bin/rails c
        conn = EmbeddedAnsible.new.api_connection
        conn.api.projects.create!(:name => "My Project", :scm_type => "git", :scm_url => "file://path/to/git/repo", :scm_update_on_launch => false, :organization => ManageIQ::Providers::EmbeddedAnsible::Provider.first.default_organization)

Comment 12 Jason Frey 2018-07-02 21:14:20 UTC
jritenou are these paths acceptable?  The first one has a presentation caveat that I'm not sure you're ok with or not.

Comment 13 jritenou 2018-07-03 13:42:01 UTC
I think either one really solves the use case, since this is primarily for demo/POC purposes, as long as we have some way of getting playbooks in without access to github or dependency on a local git service.  The only question I have is would the first method allow for adding/updating playbooks after that initial seeding?

Comment 14 Pavol Kotvan 2018-07-04 14:18:35 UTC
Hi Jason,
thanks for provided instructions. I tried 1st option and copied my playbooks into /opt/rh/cfme-gemset/gems/manageiq-content-0.1.0/content/ansible and then enabled Ansible Embedded role. I could see playbooks in Automation -> Ansible -> Playboks. When I tried order the service, I could not, because 'Repository' dropdown list required to pick repository. Please see attached screenshot.
I will test also second option.
Pavol

Comment 15 Pavol Kotvan 2018-07-04 14:20:41 UTC
Created attachment 1456516 [details]
catalog item - no repository

Comment 16 Pavol Kotvan 2018-07-05 08:21:44 UTC
Jason,
I was able to add local repo by using 2nd method you proposed. I only had to add one '/' so the path looked like this: 

:scm_url => "file:///path/to/git/repo"

Also I had to wait some time for repo to appear in the CFME UI. I tried to force provider refresh from rails console, but I did not know how.

Once repo was visible in the UI, I created catalog+catalog item and ordered it. Playbook executed without issues.

Pavol

Comment 17 Jason Frey 2018-07-17 18:06:44 UTC
Great!  Then we can document that approach (approach number 2), and I think that should be acceptable.  If updates are also required while local changes are made, that can easily be fixed by setting `:scm_update_on_launch => true` and of course leaving the on-disk repo in place (probably with a caveat of single-appliance only, or something to that effect).

gtanzillo, I'm reassigning back to you to figure out the documentation efforts, since you have that on your plate for the other Ansible RFEs anyway.  If you're not the right person, please reassign.

Comment 18 Greg Blomquist 2018-07-31 18:33:59 UTC
Brad,

Check out comment #11 follow Step 2 that Jason lays out.

Comment 19 bascar 2018-07-31 19:36:51 UTC
Jason,

Can you follow the steps in comment #11 step 2 Creating a new "repo" in EmbeddedAnsible. Does this answer you need for POC?

Comment 20 jritenou 2018-08-13 13:05:27 UTC
Those steps work and are suitable for PoC usage.  Thanks!

Comment 30 Satyajit Bulage 2018-11-22 08:28:33 UTC
Verified Version: 5.10.0.24.20181113213923_03b81fd


Note You need to log in before you can comment on or make changes to this bug.