Skip to content

Commit

Permalink
rosa create account roles as part of hc creations (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
mukrishn authored Dec 19, 2024
1 parent 1e29c69 commit 67757bd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ RUN python3 -m pip install --upgrade pip || true
RUN yes | pip3 install openshift elasticsearch==7.13.4 gitpython packaging --upgrade || true
RUN apt-get -y update
RUN apt-get -y install jq groff uuid-runtime
RUN curl -L $(curl -s https://api.github.com/repos/openshift/rosa/releases/latest | jq -r ".assets[] | select(.name == \"rosa-linux-amd64\") | .browser_download_url") --output /usr/local/bin/rosa
RUN curl -L $(curl -s https://api.github.com/repos/openshift/rosa/releases/latest | jq -r ".assets[] | select(.name == \"rosa_Linux_x86_64.tar.gz\") | .browser_download_url") --output rosa.tar.gz
RUN tar -xzf rosa.tar.gz -C /usr/local/bin/
RUN curl -L $(curl -s https://api.github.com/repos/openshift-online/ocm-cli/releases/latest | jq -r ".assets[] | select(.name == \"ocm-linux-amd64\") | .browser_download_url") --output /usr/local/bin/ocm
RUN curl -L https://releases.hashicorp.com/terraform/1.8.0/terraform_1.8.0_linux_amd64.zip -o terraform_1.8.0_linux_amd64.zip
RUN unzip terraform_1.8.0_linux_amd64.zip -d /usr/local/bin/
Expand Down
4 changes: 4 additions & 0 deletions libs/platforms/rosa/hypershift/hypershift.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def initialize(self):
self.logging.info("Verifying OIDC config")
sys.exit("Exiting") if not self._set_oidc_config() else self.logging.info(f"Using {self.environment['oidc_config_id']} as OIDC config ID")

# Create Account roles
self.logging.info("Creating ROSA Account roles")
sys.exit("Exiting") if not self._create_rosa_account_roles() else self.logging.info("Created Account roles successfully")

# Set Operator Roles
self.logging.info("Verifying Operator Roles")
if self.environment["common_operator_roles"]:
Expand Down
12 changes: 12 additions & 0 deletions libs/platforms/rosa/rosa.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ def _delete_oidc_config(self):
self.logging.info(f"Deleted oidc-config ID {self.environment['oidc_config_id']}")
return True

def _create_rosa_account_roles(self):
hc_acc_rol_code, hc_acc_rol_out, hc_acc_rol_err = self.utils.subprocess_exec(
"rosa create account-roles --hosted-cp --prefix ManagedOpenShift -y --mode auto",
extra_params={"universal_newlines": True}
)
if hc_acc_rol_code != 0:
self.logging.error("Failed to create rosa account roles")
return False
else:
self.logging.info("Create account roles successfully")
return True

def _create_operator_roles(self):
self.logging.info("Finding latest installer Role ARN")
roles_code, roles_out, roles_err = self.utils.subprocess_exec("rosa list account-roles -o json")
Expand Down

0 comments on commit 67757bd

Please sign in to comment.