Merge "Support for fine-grained distro-related defaults"
This commit is contained in:
commit
2834e3987d
@ -77,6 +77,29 @@ mainly limited to settings which are unlikely to be modified, unless a user
|
||||
has a custom Ironic Python Agent image, or needs to modify where the httpboot
|
||||
folder is set to.
|
||||
|
||||
This role has several variables that can vary between OS families,
|
||||
distributions, and their specific versions. These are specified in the
|
||||
required_defaults_* files. They are imported in a particular
|
||||
order. For example, for Ubuntu 15.04, the role will attempt to import
|
||||
the following files:
|
||||
|
||||
- required_defaults_Debian.yml
|
||||
- required_defaults_Ubuntu.yml
|
||||
- required_defaults_Ubuntu_15.04.yml
|
||||
|
||||
Not all of the possible files for a given distribution/version combination
|
||||
need to exist. The recommended approach for adding a new variable is:
|
||||
|
||||
- Put the variable in the most generic set of defaults to which it applies:
|
||||
for example, if a given variable is applicable to all Debian-family OSes,
|
||||
put it in required_defaults_Debian.yml
|
||||
|
||||
- Variables specified in the more specific files will be used to override
|
||||
values in the more generic defaults files.
|
||||
|
||||
- If a given default applies to multiple versions of a distribution, that
|
||||
variable needs to be specified for each version which it affects.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
|
@ -0,0 +1,3 @@
|
||||
---
|
||||
# NOTE(cinerama) This file is intentionally left blank - do not
|
||||
# add variables here.
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
# NOTE(cinerama): On Fedora 22, ansible 1.9, ansible_pkg_mgr
|
||||
# defaults to yum, which may not be installed. This can be safely
|
||||
# removed when we start using an ansible release which prefers dnf.
|
||||
ansible_pkg_mgr: "dnf"
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
init_template: systemd_template.j2
|
||||
init_dest_dir: /lib/systemd/system/
|
||||
init_ext: .service
|
@ -13,24 +13,27 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
---
|
||||
- name: Include OS-specific packages variables.
|
||||
# NOTE(cinerama) dummy-defaults.yml is an empty defaults file. We use it
|
||||
# here to ensure that with_first_found won't fail should we not have
|
||||
# defaults for a particular distribution, version, etc.
|
||||
- name: Include OS family-specific defaults
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "../defaults/required_defaults_{{ ansible_os_family }}_family.yml"
|
||||
- "../defaults/dummy-defaults.yml"
|
||||
- name: Include OS distribution-specific defaults
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "../defaults/required_defaults_{{ ansible_distribution }}.yml"
|
||||
- "../defaults/required_defaults_{{ ansible_os_family }}.yml"
|
||||
- "../defaults/dummy-defaults.yml"
|
||||
- name: Include OS version-specific defaults
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- "../defaults/required_defaults_{{ ansible_distribution }}_{{ ansible_distribution_version }}.yml"
|
||||
- "../defaults/dummy-defaults.yml"
|
||||
- name: "Update Package Cache"
|
||||
apt: update_cache=yes
|
||||
when: ansible_os_family == 'Debian'
|
||||
# NOTE(cinerama): On Fedora 22, ansible 1.9, ansible_pkg_mgr
|
||||
# defaults to yum, which may not be installed. This can be safely
|
||||
# removed when we start using an ansible release which prefers dnf.
|
||||
- name: "Check for dnf"
|
||||
stat: path=/usr/bin/dnf
|
||||
register: test_dnf
|
||||
- name: "Adjust ansible_pkg_mgr if dnf exists"
|
||||
set_fact:
|
||||
ansible_pkg_mgr: "dnf"
|
||||
when: ansible_distribution == 'Fedora' and "{{ test_dnf.stat.exists|bool }}"
|
||||
- name: "Install packages"
|
||||
action: "{{ ansible_pkg_mgr }} name={{ item }}"
|
||||
with_items: required_packages
|
||||
@ -146,12 +149,6 @@
|
||||
- name: "Creating authorized_keys file for ironic user"
|
||||
command: cp -p /home/ironic/.ssh/id_rsa.pub /home/ironic/.ssh/authorized_keys
|
||||
when: testing == true
|
||||
- name: "Adjust init vars for Ubuntu >= 15.04, which is systemd"
|
||||
set_fact:
|
||||
init_template: systemd_template.j2
|
||||
init_dest_dir: /lib/systemd/system/
|
||||
init_ext: .service
|
||||
when: ansible_distribution_version|version_compare('15.04', '>=') and ansible_distribution == 'Ubuntu'
|
||||
- name: "Placing services"
|
||||
template: src={{ init_template }} dest={{ init_dest_dir }}{{item.service_name}}{{ init_ext }} owner=root group=root
|
||||
with_items:
|
||||
|
Loading…
x
Reference in New Issue
Block a user