Skip to content

Commit

Permalink
Merge pull request #3 from NVIDIA-Omniverse/develop
Browse files Browse the repository at this point in the history
Develop -> Main
  • Loading branch information
myurasov-nv authored May 7, 2024
2 parents 5429122 + 5c78916 commit 38f54f3
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 18 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ WORKDIR /app
ENTRYPOINT [ "/bin/sh", "-c" ]

ENV VERSION="v2.3.0"

3 changes: 3 additions & 0 deletions deploy-alicloud
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ class AlicloudDeployer(Deployer):
if self.params["upload"]:
self.upload_user_data()

# run autorun
self.run_autorun_ansible()

# print info for the user
self.output_deployment_info()

Expand Down
3 changes: 3 additions & 0 deletions deploy-aws
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ class AWSDeployer(Deployer):
if self.params["upload"]:
self.upload_user_data()

# run autorun
self.run_autorun_ansible()

# print info for the user
self._output_deployment_info()

Expand Down
3 changes: 3 additions & 0 deletions deploy-azure
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,9 @@ class AzureDeployer(Deployer):
if self.params["upload"]:
self.upload_user_data()

# run autorun
self.run_autorun_ansible()

# connection info for the user
self.output_deployment_info()

Expand Down
3 changes: 3 additions & 0 deletions deploy-gcp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ class GCPDeployer(Deployer):
if self.params["upload"]:
self.upload_user_data()

# run autorun
self.run_autorun_ansible()

# connection info for the user
self.output_deployment_info()

Expand Down
17 changes: 11 additions & 6 deletions src/ansible/roles/isaac/tasks/isaac_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,22 @@

- name: Start Application
shell: |
export DISPLAY=":0"
if [ -f /home/{{ ansible_user }}/uploads/autorun.sh ]; then
# if autorun file is uploaded, run it
# if autorun script is present, run it
CMD="/home/{{ ansible_user }}/uploads/autorun.sh"
chmod +x "$CMD"
else
# otherwise, run Isaac Sim with default options
CMD="/home/{{ ansible_user }}/uploads/isaacsim.sh"
CMD="/home/{{ ansible_user }}/Desktop/isaacsim.sh"
fi
chmod +x "$CMD"
export DISPLAY=:0
# wait for display to become available
while ! xset q > /dev/null 2>&1 ; do
echo "Waiting for the display to become available..."
sleep 1
done
# run in a terminal on desktop
gnome-terminal -- bash -c "$CMD; exec bash"
args:
Expand All @@ -94,4 +99,4 @@
tags:
- skip_in_image
- on_stop_start
- _autorun
- autorun
56 changes: 44 additions & 12 deletions src/python/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,20 +235,22 @@ def create_tfvars(self, tfvars: dict = {}):
# default values common for all clouds
tfvars.update(
{
"isaac_enabled": self.params["isaac"]
if "isaac" in self.params
else False,
"isaac_enabled": (
self.params["isaac"] if "isaac" in self.params else False
),
#
"isaac_instance_type": self.params["isaac_instance_type"]
if "isaac_instance_type" in self.params
else "none",
"isaac_instance_type": (
self.params["isaac_instance_type"]
if "isaac_instance_type" in self.params
else "none"
),
#
"prefix": self.params["prefix"],
"ssh_port": self.params["ssh_port"],
#
"from_image": self.params["from_image"]
if "from_image" in self.params
else False,
"from_image": (
self.params["from_image"] if "from_image" in self.params else False
),
#
"deployment_name": self.params["deployment_name"],
}
Expand Down Expand Up @@ -412,17 +414,33 @@ def export_ssh_key(self):
verbose=debug,
)

def run_ansible(self, playbook_name: str, cwd: str):
def run_ansible(
self,
playbook_name: str,
cwd: str,
tags: [str] = [],
skip_tags: [str] = [],
):
"""
Run Ansible playbook via shell command
"""

debug = self.params["debug"]
deployment_name = self.params["deployment_name"]

if len(tags) > 0:
tags = ",".join([f'--tags "{tag}"' for tag in tags])
else:
tags = ""

if len(skip_tags) > 0:
skip_tags = ",".join([f'--skip-tags "{tag}"' for tag in skip_tags])
else:
skip_tags = ""

shell_command(
f"ansible-playbook -i {self.config['state_dir']}/{deployment_name}/.inventory "
+ f"{playbook_name}.yml {'-vv' if self.params['debug'] else ''}",
+ f"{playbook_name}.yml {tags} {skip_tags} {'-vv' if self.params['debug'] else ''}",
cwd=cwd,
verbose=debug,
)
Expand All @@ -431,14 +449,28 @@ def run_all_ansible(self):
# run ansible for isaac
if "isaac" in self.params and self.params["isaac"]:
click.echo(colorize_info("* Running Ansible for Isaac Sim..."))
self.run_ansible(playbook_name="isaac", cwd=f"{self.config['ansible_dir']}")
self.run_ansible(
playbook_name="isaac",
cwd=f"{self.config['ansible_dir']}",
skip_tags=["autorun"], # autorun should be executed after the upload
)

# run ansible for ovami
# todo: move to ./deploy-aws
if "ovami" in self.params and self.params["ovami"]:
click.echo(colorize_info("* Running Ansible for OV AMI..."))
self.run_ansible(playbook_name="ovami", cwd=f"{self.config['ansible_dir']}")

def run_autorun_ansible(self):
# run ansible for isaac
if "isaac" in self.params and self.params["isaac"]:
click.echo(colorize_info("* Running autorun Ansible for Isaac Sim..."))
self.run_ansible(
playbook_name="isaac",
cwd=f"{self.config['ansible_dir']}",
tags=["autorun"],
)

def tf_output(self, key: str, default: str = ""):
"""
Read Terraform output.
Expand Down
4 changes: 4 additions & 0 deletions uploads/autorun.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/sh

# This script is executed when
# 1. the VM is first deployed
# 2. the VM is started after being stopped

# replace with your own command
# for example:
# ~ubuntu/Desktop/isaacsim.sh --cmd="/isaac-sim/kit/kit /isaac-sim/apps/omni.isaac.sim.kit --allow-root"
Expand Down

0 comments on commit 38f54f3

Please sign in to comment.