Skip to content

Commit 5f4b938

Browse files
author
mstanescu_adobe
committed
[AAM-65858] Add ops-cli Teleport support
1 parent 8246f18 commit 5f4b938

File tree

14 files changed

+428
-199
lines changed

14 files changed

+428
-199
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/
762762
763763
## Running tests
764764
765-
- on your machine: `py.test tests`
765+
- on your machine: `python -m pytest tests` or `build_scripts/run_tests.sh`
766766
767767
# Troubleshooting
768768

src/ops/cli/inventory.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def run(self, args, extra_args):
5555
group_string = ", ".join(group_names)
5656
host_id = host.vars.get('ec2_InstanceId', '')
5757
if host_id != '':
58-
name_and_id = "%s -- %s" % (stringc(host.name,
59-
'blue'), stringc(host_id, 'blue'))
58+
name_and_id = "%s -- %s" % (stringc(self.get_ec2_hostname(host), 'blue'),
59+
stringc(host.name, 'blue'))
6060
else:
6161
name_and_id = "%s" % stringc(host.name, 'blue')
6262
display("%s (%s)" % (name_and_id, stringc(group_string, 'green')))
@@ -68,6 +68,9 @@ def get_inventory_hosts(self, args):
6868

6969
return self.ansible_inventory.get_hosts(limit)
7070

71+
def get_ec2_hostname(self, host):
72+
return host.vars.get('ec2_tag_Adobe_FQDN') or host.vars.get('ec2_tag_CMDB_hostname') or ''
73+
7174
def get_host_facts(self, host, indent="\t"):
7275
vars = host.get_vars()
7376
ret = yaml.dump(

src/ops/cli/parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,5 +112,7 @@ def configure_common_ansible_args(parser):
112112
parser.add_argument('--noscb', action='store_false', dest='use_scb',
113113
help='Disable use of Shell Control Box (SCB) even if '
114114
'it is enabled in the cluster config')
115+
parser.add_argument('--teleport', action='store_false', dest='use_teleport',
116+
help='Use Teleport for SSH')
115117

116118
return parser

src/ops/cli/playbook.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ def __init__(self, ops_config, root_dir, inventory_generator,
7373
def run(self, args, extra_args):
7474
logger.info("Found extra_args %s", extra_args)
7575
inventory_path, ssh_config_paths = self.inventory_generator.generate()
76-
ssh_config_path = SshConfigGenerator.get_ssh_config_path(self.cluster_config,
76+
ssh_config_generator = SshConfigGenerator(self.ops_config.package_dir)
77+
ssh_config_path = ssh_config_generator.get_ssh_config_path(self.cluster_config,
7778
ssh_config_paths,
78-
args.use_scb)
79+
args)
80+
7981
ssh_config = f"ANSIBLE_SSH_ARGS='-F {ssh_config_path}'"
8082

8183
ansible_config = "ANSIBLE_CONFIG=%s" % self.ops_config.ansible_config_path

src/ops/cli/run.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ def run(self, args, extra_args):
6868
logger.info("Found extra_args %s", extra_args)
6969
inventory_path, ssh_config_paths = self.inventory_generator.generate()
7070
limit = args.host_pattern
71-
ssh_config_path = SshConfigGenerator.get_ssh_config_path(self.cluster_config,
71+
ssh_config_generator = SshConfigGenerator(self.ops_config.package_dir)
72+
ssh_config_path = ssh_config_generator.get_ssh_config_path(self.cluster_config,
7273
ssh_config_paths,
73-
args.use_scb)
74+
args)
7475
extra_args = ' '.join(args.extra_args)
7576
command = """cd {root_dir}
7677
ANSIBLE_SSH_ARGS='-F {ssh_config}' ANSIBLE_CONFIG={ansible_config_path} ansible -i {inventory_path} '{limit}' \\

0 commit comments

Comments
 (0)