We want to get rid of relative paths in playbooks and
tasks, and in order to do that we have to provide Ansible
with some more information.
base is the directory where lcitool lives, and
playbook_base is the directory where a playbook should
look for its private resources: they match for the time
being, but that will no longer be the case very shortly.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
guests/lcitool | 5 ++++-
guests/site.yml | 26 +++++++++++++-------------
guests/tasks/base.yml | 6 +++---
guests/tasks/jenkins.yml | 4 ++--
guests/tasks/packages.yml | 2 +-
guests/tasks/users.yml | 4 ++--
6 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/guests/lcitool b/guests/lcitool
index 4acb076..206a014 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -431,9 +431,12 @@ class Application:
ansible_hosts = ",".join(self._inventory.expand_pattern(hosts))
ansible_cfg_path = os.path.join(base, "ansible.cfg")
- playbook_path = os.path.join(base, "site.yml")
+ playbook_base = base
+ playbook_path = os.path.join(playbook_base, "site.yml")
extra_vars = json.dumps({
+ "base": base,
+ "playbook_base": playbook_base,
"root_password_file": root_pass_file,
"flavor": flavor,
})
diff --git a/guests/site.yml b/guests/site.yml
index 063b0c6..4de759b 100644
--- a/guests/site.yml
+++ b/guests/site.yml
@@ -6,33 +6,33 @@
tasks:
# Bootstrap Ansible itself
- - include: tasks/bootstrap.yml
+ - include: '{{ playbook_base }}/tasks/bootstrap.yml'
- hosts: all
remote_user: root
vars_files:
- - vars/mappings.yml
+ - '{{ base }}/vars/mappings.yml'
tasks:
# Prepare environment. None of the actions performed here might
# depend on packages being installed
- - include: tasks/base.yml
+ - include: '{{ playbook_base }}/tasks/base.yml'
# Install base packages
- - include: tasks/packages.yml
+ - include: '{{ playbook_base }}/tasks/packages.yml'
vars:
project: base
# Remove blacklisted packages
- - include: tasks/packages.yml
+ - include: '{{ playbook_base }}/tasks/packages.yml'
vars:
project: blacklist
state: absent
# Install build dependencies for each project
- - include: tasks/packages.yml
+ - include: '{{ playbook_base }}/tasks/packages.yml'
with_items:
'{{ projects }}'
loop_control:
@@ -41,20 +41,20 @@
- projects is defined
# Install packages needed for the Jenkins agent
- - include: tasks/packages.yml
+ - include: '{{ playbook_base }}/tasks/packages.yml'
vars:
project: jenkins
when:
- flavor == "jenkins"
# Configure environment. Needs to happen after installing packages
- - include: tasks/paths.yml
- - include: tasks/bootloader.yml
- - include: tasks/services.yml
- - include: tasks/kludges.yml
- - include: tasks/users.yml
+ - include: '{{ playbook_base }}/tasks/paths.yml'
+ - include: '{{ playbook_base }}/tasks/bootloader.yml'
+ - include: '{{ playbook_base }}/tasks/services.yml'
+ - include: '{{ playbook_base }}/tasks/kludges.yml'
+ - include: '{{ playbook_base }}/tasks/users.yml'
# Configure the Jenkins agent
- - include: tasks/jenkins.yml
+ - include: '{{ playbook_base }}/tasks/jenkins.yml'
when:
- flavor == 'jenkins'
diff --git a/guests/tasks/base.yml b/guests/tasks/base.yml
index 6310d96..11f600f 100644
--- a/guests/tasks/base.yml
+++ b/guests/tasks/base.yml
@@ -25,7 +25,7 @@
- name: Enable jessie-backports repository
template:
- src: templates/jessie-backports.sources.j2
+ src: '{{ playbook_base }}/templates/jessie-backports.sources.j2'
dest: /etc/apt/sources.list.d/jessie-backports.list
owner: root
group: root
@@ -36,7 +36,7 @@
- name: Configure APT pinning for jessie-backports
template:
- src: templates/jessie-backports.preferences.j2
+ src: '{{ playbook_base }}/templates/jessie-backports.preferences.j2'
dest: /etc/apt/preferences.d/jessie-backports
owner: root
group: root
@@ -47,7 +47,7 @@
- name: Enable fedora-rawhide-kernel-nodebug repository
template:
- src: templates/fedora-rawhide-kernel-nodebug.repo.j2
+ src: '{{ playbook_base }}/templates/fedora-rawhide-kernel-nodebug.repo.j2'
dest: /etc/yum.repos.d/fedora-rawhide-kernel-nodebug.repo
owner: root
group: root
diff --git a/guests/tasks/jenkins.yml b/guests/tasks/jenkins.yml
index 9076c34..479e5d6 100644
--- a/guests/tasks/jenkins.yml
+++ b/guests/tasks/jenkins.yml
@@ -1,7 +1,7 @@
---
- name: Open vault
include_vars:
- file: vars/vault.yml
+ file: '{{ base }}/vars/vault.yml'
- name: Look up Jenkins secret
set_fact:
@@ -32,7 +32,7 @@
- name: Configure Jenkins agent
template:
- src: templates/jenkins.service.j2
+ src: '{{ playbook_base }}/templates/jenkins.service.j2'
dest: /etc/systemd/system/jenkins.service
when:
- jenkins_secret is defined
diff --git a/guests/tasks/packages.yml b/guests/tasks/packages.yml
index 718ef47..a725b07 100644
--- a/guests/tasks/packages.yml
+++ b/guests/tasks/packages.yml
@@ -7,7 +7,7 @@
- name: '{{ project }}: Load variables'
include_vars:
- file: 'vars/projects/{{ project }}.yml'
+ file: '{{ base }}/vars/projects/{{ project }}.yml'
- set_fact:
temp: {}
diff --git a/guests/tasks/users.yml b/guests/tasks/users.yml
index dd6c39d..ec7f798 100644
--- a/guests/tasks/users.yml
+++ b/guests/tasks/users.yml
@@ -61,7 +61,7 @@
- name: '{{ flavor }}: Configure ccache'
template:
- src: templates/ccache.conf.j2
+ src: '{{ playbook_base }}/templates/ccache.conf.j2'
dest: /home/{{ flavor }}/.ccache/ccache.conf
owner: '{{ flavor }}'
group: '{{ flavor }}'
@@ -96,7 +96,7 @@
- name: '{{ flavor }}: Create shell profile'
template:
- src: templates/{{ item }}.j2
+ src: '{{ playbook_base }}/templates/{{ item }}.j2'
dest: /home/{{ flavor }}/.{{ item }}
owner: '{{ flavor }}'
group: '{{ flavor }}'
--
2.17.1