-
Notifications
You must be signed in to change notification settings - Fork 898
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
Expose plugin ansible content consolidation as a rake task #17407
Changes from 3 commits
8c32282
7e090f5
9b6fe1e
f8568b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,14 @@ | |
require "securerandom" | ||
|
||
class ApplianceEmbeddedAnsible < EmbeddedAnsible | ||
TOWER_VERSION_FILE = "/var/lib/awx/.tower_version".freeze | ||
SETUP_SCRIPT = "ansible-tower-setup".freeze | ||
SECRET_KEY_FILE = "/etc/tower/SECRET_KEY".freeze | ||
SETTINGS_FILE = "/etc/tower/settings.py".freeze | ||
EXCLUDE_TAGS = "packages,migrations,firewall".freeze | ||
HTTP_PORT = 54_321 | ||
HTTPS_PORT = 54_322 | ||
TOWER_VERSION_FILE = "/var/lib/awx/.tower_version".freeze | ||
SETUP_SCRIPT = "ansible-tower-setup".freeze | ||
SECRET_KEY_FILE = "/etc/tower/SECRET_KEY".freeze | ||
SETTINGS_FILE = "/etc/tower/settings.py".freeze | ||
EXCLUDE_TAGS = "packages,migrations,firewall".freeze | ||
HTTP_PORT = 54_321 | ||
HTTPS_PORT = 54_322 | ||
CONSOLIDATED_PLUGIN_PLAYBOOKS_TEMPDIR = Pathname.new("/var/lib/awx_consolidated_source").freeze | ||
|
||
def self.available? | ||
require "linux_admin" | ||
|
@@ -70,6 +71,32 @@ def api_connection | |
api_connection_raw("localhost", HTTP_PORT) | ||
end | ||
|
||
def create_local_playbook_repo | ||
self.class.consolidate_plugin_playbooks(playbook_repo_path) | ||
|
||
Dir.chdir(playbook_repo_path) do | ||
require 'rugged' | ||
repo = Rugged::Repository.init_at(".") | ||
index = repo.index | ||
index.add_all("*") | ||
index.write | ||
|
||
options = {} | ||
options[:tree] = index.write_tree(repo) | ||
options[:author] = options[:committer] = { :email => "system@localhost", :name => "System", :time => Time.now.utc } | ||
options[:message] = "Initial Commit" | ||
options[:parents] = [] | ||
options[:update_ref] = 'HEAD' | ||
Rugged::Commit.create(repo, options) | ||
end | ||
|
||
FileUtils.chown_R('awx', 'awx', playbook_repo_path) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does awx own the repo? I know that was there before, but that doesn't make any sense to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jrafanie ? I know the tower processes run as the awx user, but if it's just copying off the files it seems like it wouldn't need to own the directory. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The assumption was the awx user would be reading this git repo's path when we posted this local path for the new project. If it has permission to read in all situations, then this can be removed. |
||
end | ||
|
||
def playbook_repo_path | ||
CONSOLIDATED_PLUGIN_PLAYBOOKS_TEMPDIR | ||
end | ||
|
||
private | ||
|
||
def upgrade? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,4 +130,10 @@ namespace :evm do | |
end | ||
EvmDatabase.raise_server_event(opts[:event]) | ||
end | ||
|
||
desc "Write all plugin ansible content to a directory" | ||
task :write_plugin_ansible_content => :environment do | ||
dest_dir = ENV["ANSIBLE_CONTENT_DIR"] || Rails.root.join("tmp", "ansible_content") | ||
EmbeddedAnsible.consolidate_plugin_playbooks(dest_dir) | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, this just copies the content but doesn't set up git? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. |
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised there isn't a master branch. Does awx/tower only reference the HEAD commit anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a master branch after everything is set up. Is that just the default behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is probably using the default behavior.