New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature-add] Added role to rename engine #132

Merged
merged 12 commits into from Aug 16, 2017
Copy path View file
@@ -37,7 +37,7 @@ script:
# Run sytax checks and linters
- tox
# Execute oVirt engine deployment playbook
- ansible-playbook tests/test-${TEST_NAME}.yml -i tests/inventory
- ansible-playbook tests/test-${TEST_NAME}.yml -i tests/inventory -vvv

This comment has been minimized.

@StLuke

StLuke Jun 23, 2017

Collaborator

1st thought - verbose mode should go out
2nd - @lukas-bednar actually wouldnt it be nice to have verbose mode enabled in tests? :)

This comment has been minimized.

@lukas-bednar

lukas-bednar Jun 23, 2017

Member

@StLuke I am ok with it ... if we find it annoying we can disable it later.


notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
Copy path View file
@@ -49,6 +49,7 @@ This host group is meant for virtual machines hosted by oVirt Engine.
* [ovirt-engine-setup]
* [ovirt-guest-agent]
* [ovirt-iso-uploader-conf]
* [ovirt-engine-rename]

## Example

@@ -124,3 +125,4 @@ ansible-playbook tests/test-master.yml -i tests/inventory
[ovirt-guest-agent]: https://github.com/rhevm-qe-automation/ovirt-ansible/blob/master/roles/ovirt-guest-agent/README.md
[provision_docker]: https://github.com/chrismeyersfsu/provision_docker/
[ovirt-iso-uploader-conf]: https://github.com/rhevm-qe-automation/ovirt-ansible/blob/master/roles/ovirt-iso-uploader-conf/README.md
[ovirt-engine-rename]: https://github.com/rhevm-qe-automation/ovirt-ansible/blob/master/roles/ovirt-engine-rename/README.md
@@ -0,0 +1,38 @@
oVirt Engine Rename

This comment has been minimized.

@lukas-bednar

lukas-bednar Jun 23, 2017

Member

Could you please update README.md in the root of repository, and add link to this file?
Under "Implemented roles" section.

https://github.com/rhevm-qe-automation/ovirt-ansible#implemented-roles

This comment has been minimized.

@tasdikrahman

tasdikrahman Aug 9, 2017

Contributor

added

===================

Role to change ovirt-engine fqdn and re-enroll all the related certificates

Target Systems
--------------

* engine

Requirements
------------

- Preinstalled clean environment with configured repositories and a working engine installation
- New internally resolvable hostname

Role Variables
--------------

- `ovirt_engine_rename_new_fqdn`: new ovirt-engine hostname

Example Playbook
----------------

```yaml
---
- hosts: engine
vars:
ovirt_engine_rename_new_fqdn: 'ovirt-rename-testing.gsoc.org'
roles:
- role: ovirt-engine-rename
```

Author Information
------------------

Tasdik Rahman
tasdik95@gmail.com
@@ -0,0 +1,11 @@
---
# delete the temp file which was created for grep comparison
- name: delete engine-rename engine rename logs
file:
path: '/tmp/engine-rename-logs-current.grep'
state: 'absent'

- name: delete engine-rename expected log files
file:
path: '/tmp/check-engine-name-expected-result.grep'
state: 'absent'
@@ -0,0 +1,73 @@
---
# grep returns an exit code of 1 when it doesn't match any lines. Ansible then
# interprets this (actually any status code other than 0 from a shell/command
# task) as an error and so promptly fails.
- name: Register the engine name stored inside the files in directory `/etc/ovirt-engine`
command: grep -R --include \*.conf {{ ovirt_engine_rename_new_fqdn }} /etc/ovirt-engine
register: grep_output_remote_run
changed_when: False
failed_when: "grep_output_remote_run.rc == 2"
ignore_errors: yes

- name: Saving the above diff result
copy: content="{{ grep_output_remote_run.stdout }}" dest=/tmp/engine-rename-logs-current.grep
notify:
- delete engine-rename engine rename logs

- debug: msg="The command grep -R {{ ovirt_engine_rename_new_fqdn }} /etc/ovirt-engine returned {{ grep_output_remote_run.stdout }}"

- name: Copy the expected result to /tmp on the remote vm to be compared with existing engine-rename logs
template:
src: check-engine-name-expected-result.grep.j2
dest: /tmp/check-engine-name-expected-result.grep
notify:
- delete engine-rename expected log files

# if the engine-name is already at the state where we want it to be
- name: Comparing the grep diff for the one that we expect and the one we just ran
command: diff --ignore-all-space /tmp/check-engine-name-expected-result.grep /tmp/engine-rename-logs-current.grep
register: grep_diff
changed_when: False
failed_when: "grep_diff.rc == 2"
ignore_errors: yes

- name: Running engine-rename command (if the engine-name diff stdout != "")
shell: |
/usr/share/ovirt-engine/setup/bin/ovirt-engine-rename \
--newname={{ ovirt_engine_rename_new_fqdn }} \
--otopi-environment="OSETUP_RENAME/forceIgnoreAIAInCA=bool:'True' \
OVESETUP_CORE/engineStop=bool:'True' \
OSETUP_RENAME/confirmForceOverwrite=bool:'False'"
when: grep_diff.stdout != ""
# ^ i.e skip when engine-name is already at the state we want it to be
tags:
- skip_ansible_lint

# this is optional and is to be commented out if your systems use the DNS
# to get the hostname, if not let it remain
- name: Changing the system host name to reflect the new engine-name

This comment has been minimized.

This comment has been minimized.

@StLuke

StLuke Jun 23, 2017

Collaborator

also this should be disabled by default, and enabled in tests by some variable (dont forget to add it to README.md
Some varuable such as ovirt_engine_rename_change_engine_hostname = False

This comment has been minimized.

@StLuke

This comment has been minimized.

@tasdikrahman

tasdikrahman Aug 16, 2017

Contributor

@StLuke As discussed, I proposed that this line can be left/commented out when the playbook is being run and the use of hostname module as you suggested gave rise to the same DBUS error which was previously being faced when using the command hostnamectl set-hostname new-hostname as discussed here in this #132 (comment)

# command: hostnamectl set-hostname {{ ovirt_engine_rename_new_fqdn }}
command: hostname {{ ovirt_engine_rename_new_fqdn }}
tags:
- skip_ansible_lint

- debug: msg="change your /etc/hosts file to reflect to the new changed ovirt-engine name"

- name: Checking if the engine-rename is successful
command: grep -R --include \*.conf {{ ovirt_engine_rename_new_fqdn }} /etc/ovirt-engine
changed_when: False
register: final_check

- name: Engine rename successful or not?
command: echo Engine Rename successful
changed_when: False
when: final_check.rc == 0

- name: check health status of page
uri:
url: "http://{{ ovirt_engine_rename_new_fqdn }}/ovirt-engine/services/health"
status_code: 200
register: health_page
retries: 12
delay: 10
until: health_page|success
@@ -0,0 +1,4 @@
/etc/ovirt-engine/engine.conf.d/10-setup-protocols.conf:ENGINE_FQDN={{ovirt_engine_rename_new_fqdn}}
/etc/ovirt-engine/ovirt-vmconsole-proxy-helper.conf.d/10-setup.conf:ENGINE_BASE_URL=http://{{ovirt_engine_rename_new_fqdn}}:80/ovirt-engine/
/etc/ovirt-engine/isouploader.conf.d/10-engine-setup.conf:engine={{ovirt_engine_rename_new_fqdn}}:443
/etc/ovirt-engine/logcollector.conf.d/10-engine-setup.conf:engine={{ovirt_engine_rename_new_fqdn}}:443
Copy path View file
@@ -0,0 +1,7 @@
---
- name: Run ovirt-engine-rename on containerized environment
hosts: engine
vars:
ovirt_engine_rename_new_fqdn: 'test.ovirt.org'
roles:
- role: ovirt-engine-rename
Copy path View file
@@ -7,6 +7,7 @@
vars:
ovirt_engine_version: "3.6"
ovirt_rpm_repo: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release36.rpm"
- include: engine-rename.yml
- include: engine-cleanup.yml
vars:
ovirt_engine_version: "3.6"
Copy path View file
@@ -7,6 +7,7 @@
vars:
ovirt_engine_version: "4.0"
ovirt_rpm_repo: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release40.rpm"
- include: engine-rename.yml
- include: engine-cleanup.yml
vars:
ovirt_engine_version: "4.0"
Copy path View file
@@ -5,6 +5,7 @@
vars:
ovirt_engine_version: "4.1"
ovirt_rpm_repo: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release41.rpm"
- include: engine-rename.yml
- include: engine-cleanup.yml
vars:
ovirt_engine_version: "4.1"
Copy path View file
@@ -5,6 +5,7 @@
vars:
ovirt_engine_version: "4.2"
ovirt_rpm_repo: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release-master.rpm"
- include: engine-rename.yml
- include: engine-cleanup.yml
vars:
ovirt_engine_version: "4.2"
@@ -9,6 +9,7 @@
vars:
ovirt_engine_version: "4.2"
ovirt_rpm_repo: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release-master.rpm"
- include: engine-rename.yml
- include: engine-cleanup.yml
vars:
ovirt_engine_version: "4.2"
ProTip! Use n and p to navigate between commits in a pull request.