Skip to content

Commit

Permalink
Merge pull request ComplianceAsCode#11542 from dmc5179/rhel9
Browse files Browse the repository at this point in the history
Add RHEL 9 support for playbook to role conversion utility
  • Loading branch information
Mab879 authored Feb 13, 2024
2 parents 1513fcb + a5a3052 commit 89a8eda
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions utils/ansible_playbook_to_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def dict_constructor(loader, node):
PRODUCT_ALLOWLIST = set([
"rhel7",
"rhel8",
"rhel9",
])

PROFILE_ALLOWLIST = set([
Expand All @@ -80,6 +81,8 @@ def dict_constructor(loader, node):
"stig",
"rhvh-stig",
"rhvh-vpp",
"e8",
"ism",
])


Expand Down Expand Up @@ -118,7 +121,7 @@ def clone_and_init_repository(parent_dir, organization, repo):
os.system('git add .')
os.system('git commit -a -m "Initial commit" --author "%s <%s>"'
% (GIT_COMMIT_AUTHOR_NAME, GIT_COMMIT_AUTHOR_EMAIL))
os.system('git push origin master')
os.system('git push origin main')
finally:
os.chdir("..")

Expand Down Expand Up @@ -423,7 +426,7 @@ def _get_blob_content(self, branch, path_name):
b64 = base64.b64decode(blob.content)
return (b64.decode("utf8"), sha[0])

def _get_contents(self, path_name, branch='master'):
def _get_contents(self, path_name, branch='main'):
"""
First try to use traditional's github API to get package contents,
since this API can't fetch file size more than 1MB, use another API when failed.
Expand All @@ -440,7 +443,13 @@ def _get_contents(self, path_name, branch='master'):

def _remote_content(self, filepath):
# We want the raw string to compare against _local_content
content, sha = self._get_contents(filepath)

# New repos use main instead of master
branch = 'master'
if "rhel9" in self.remote_repo.full_name:
branch = 'main'

content, sha = self._get_contents(filepath, branch)
return content, sha

def _update_content_if_needed(self, filepath):
Expand Down

0 comments on commit 89a8eda

Please sign in to comment.