Skip to content

Commit 04dcdea

Browse files
committed
feat: simplify commands using ansible_user
Some commands such as accessing the control host via SSH or running the playbooks relies on the `ansible_user` to be defined which is typically either `ubuntu` or `cloud-user`. To make this easy we can reuse and export the variable `ssh_user` which is assigned by the user within `terraform.tfvars`. This should be set to the user for accessing the machine. Once set and `terraform apply` executed users can ssh using the command on line 215 verbatim. The same can be said for the ansible-playbook commands.
1 parent 03adeb7 commit 04dcdea

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ If not you can skip those playbook and proceed onto `deploy-openstack-config` wh
196196
Be sure to replace `ansible_user` with the user you are using to connect to the Ansible control host.
197197
.. code-block:: console
198198
199-
ansible-playbook -i ansible/inventory.yml ansible/fix-homedir-ownership.yml -e ansible_user=cloud-user
200-
ansible-playbook -i ansible/inventory.yml ansible/add-fqdn.yml -e ansible_user=cloud-user
201-
ansible-playbook -i ansible/inventory.yml ansible/grow-control-host.yml -e ansible_user=cloud-user
202-
ansible-playbook -i ansible/inventory.yml ansible/deploy-openstack-config.yml -e ansible_user=cloud-user
199+
ansible-playbook -i ansible/inventory.yml ansible/fix-homedir-ownership.yml
200+
ansible-playbook -i ansible/inventory.yml ansible/add-fqdn.yml
201+
ansible-playbook -i ansible/inventory.yml ansible/grow-control-host.yml
202+
ansible-playbook -i ansible/inventory.yml ansible/deploy-openstack-config.yml
203203
204204
Deploy OpenStack
205205
----------------
@@ -212,7 +212,7 @@ If you choose to opt for automated method you must first SSH into your Ansible c
212212

213213
.. code-block:: console
214214
215-
ssh cloud-user@$(terraform output -raw ansible_control_access_ip_v4)
215+
ssh $(terraform output -raw ansible_user)@$(terraform output -raw ansible_control_access_ip_v4)
216216
~/deploy-openstack.sh
217217
218218
This script will go through the process of performing the following tasks

outputs.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ output "seed_access_ip_v4" {
66
value = openstack_compute_instance_v2.seed.access_ip_v4
77
}
88

9+
output "ansible_user" {
10+
value = var.ssh_user
11+
}
12+
913
resource "local_file" "hosts" {
1014
content = templatefile(
1115
"${path.module}/templates/hosts.tpl",
@@ -97,4 +101,7 @@ resource "ansible_host" "storage" {
97101
resource "ansible_group" "cluster_group" {
98102
name = "cluster"
99103
children = ["compute", "ansible_control", "controllers", "seed", "storage"]
104+
variables = {
105+
ansible_user = var.ssh_user
106+
}
100107
}

templates/deploy-openstack.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ set +x
6060
source $${KOLLA_CONFIG_PATH}/public-openrc.sh
6161
set -x
6262

63-
~/src/openstack-config/tools/openstack-config
63+
~/src/openstack-config/tools/openstack-config -- -e ansible_user=${ ssh_user }
6464

6565
git -C $${config_directories[kayobe]} submodule init
6666
git -C $${config_directories[kayobe]} submodule update

0 commit comments

Comments
 (0)