This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting instance host name (#161)
* molecule_vagrant/modules/vagrant.py: Allow setting instance host name It may be useful to be able to set the instance hostname/FQDN or to prevent vagrant to set the hostname, so add support for that. The default behaviour is unchanged: the host name is set to the instance name. Fixes: #157 Signed-off-by: Arnaud Patard <[email protected]> * tools/test-setup.sh: Fix handling of manually installed vagrant package version This commit is solving two issues: - Vagrant 2.2.10 is needed at least, otherwise it will fail to properly set the hostname. 2.2.10 is already installed with manual rpm installation but not for bionic - Vagrant version for manually installed package is not the same for rpm and bionic, so rely on a variable to ensure consistency. Signed-off-by: Arnaud Patard <[email protected]> Co-authored-by: Sorin Sbarnea <[email protected]>
- Loading branch information
Showing
8 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
molecule_vagrant/test/scenarios/molecule/hostname/converge.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
gather_facts: false | ||
become: true | ||
tasks: | ||
- name: sample task # noqa 305 | ||
ansible.builtin.shell: | ||
cmd: uname | ||
warn: false | ||
changed_when: false |
24 changes: 24 additions & 0 deletions
24
molecule_vagrant/test/scenarios/molecule/hostname/molecule.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
dependency: | ||
name: galaxy | ||
driver: | ||
name: vagrant | ||
provider: | ||
name: libvirt | ||
platforms: | ||
- name: instance-1 | ||
box: ${TESTBOX:-debian/jessie64} | ||
memory: 256 | ||
cpus: 1 | ||
- name: instance-2 | ||
hostname: instance.example.com | ||
box: ${TESTBOX:-debian/jessie64} | ||
memory: 256 | ||
cpus: 1 | ||
- name: instance-3 | ||
hostname: false | ||
box: ${TESTBOX:-debian/jessie64} | ||
memory: 256 | ||
cpus: 1 | ||
provisioner: | ||
name: ansible |
33 changes: 33 additions & 0 deletions
33
molecule_vagrant/test/scenarios/molecule/hostname/verify.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
- name: Check instance-1 | ||
hosts: instance-1 | ||
gather_facts: true | ||
gather_subset: | ||
- min | ||
tasks: | ||
- name: Ensure that host name is instance-1 | ||
ansible.builtin.assert: | ||
that: | ||
- ansible_fqdn == "instance-1" | ||
|
||
- name: Check instance-2 | ||
hosts: instance-2 | ||
gather_facts: true | ||
gather_subset: | ||
- min | ||
tasks: | ||
- name: Ensure that host name is instance.example.com | ||
ansible.builtin.assert: | ||
that: | ||
- ansible_fqdn == "instance.example.com" | ||
|
||
- name: Check instance-3 | ||
hosts: instance-3 | ||
gather_facts: true | ||
gather_subset: | ||
- min | ||
tasks: | ||
- name: Ensure that host name is not instance-3 | ||
ansible.builtin.assert: | ||
that: | ||
- ansible_fqdn != "instance-3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters