7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'app/lib/foreman_ansible_director/generators/content_generator.rb', line 7
def generate(host:,
resolved_host_content:)
content = {}
resolved_host_content.each do |content_assignment|
consumable = content_assignment[:cuv]
next unless consumable
if consumable.is_a? ::ForemanAnsibleDirector::AnsibleCollectionRole
cuv = consumable.ansible_collection_version
cu = cuv.versionable
else cuv = consumable
cu = consumable.versionable
end
if cuv.source_type == 'git'
distribution_suffix = Base64.encode64(cuv.version[0, 16]).strip
source = "https://#{SETTINGS[:fqdn]}/pulp_ansible/galaxy/#{host.organization_id}/#{cu.full_name}-#{cuv.source_type}-#{distribution_suffix}"
next if content.key? source
content[source] = {
type: cu.type == 'ForemanAnsibleDirector::AnsibleCollection' ? 'collection' : 'role',
identifier: cu.full_name,
source: source,
}
else
source = "https://#{SETTINGS[:fqdn]}/pulp_ansible/galaxy/#{host.organization_id}/#{cu.full_name}-#{cuv.source_type}"
next if content.key? [source, cuv.version]
content[[source, cuv.version]] = {
type: cu.type == 'ForemanAnsibleDirector::AnsibleCollection' ? 'collection' : 'role',
identifier: cu.full_name,
version: cuv.version,
source: "https://#{SETTINGS[:fqdn]}/pulp_ansible/galaxy/#{host.organization_id}/#{cu.full_name}-#{cuv.source_type}",
}
end
end
content.values
end
|