From bc3483f223e8d2c0b3fa0f0b8718f9d837f6f6ae Mon Sep 17 00:00:00 2001 From: Dmitry Shulyak Date: Fri, 16 Oct 2015 13:14:33 +0300 Subject: [PATCH] Add mos_repos virtual resource and use it for ceph example --- examples/library_ceph/README.md | 6 ++++ examples/library_ceph/ceph.py | 6 +++- resources/apt_repo/actions/remove.yaml | 9 ++++++ resources/apt_repo/actions/run.yaml | 6 ++-- resources/apt_repo/meta.yaml | 5 ++- resources/apt_repo/templates/source | 1 + resources/managed_apt/actions/run.yaml | 1 + templates/mos_repos.yaml | 43 ++++++++++++++++++++++++++ 8 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 resources/apt_repo/actions/remove.yaml create mode 100644 resources/apt_repo/templates/source create mode 100644 templates/mos_repos.yaml diff --git a/examples/library_ceph/README.md b/examples/library_ceph/README.md index 743aa58c..1e19af44 100644 --- a/examples/library_ceph/README.md +++ b/examples/library_ceph/README.md @@ -22,3 +22,9 @@ debug info. ``` solar res action run ceph_mon1 ``` + +To add repositories use + +``` +solar resource create apt1 templates/mos_repos.yaml node=node1 index=1 +``` diff --git a/examples/library_ceph/ceph.py b/examples/library_ceph/ceph.py index b48ade0d..a59de745 100644 --- a/examples/library_ceph/ceph.py +++ b/examples/library_ceph/ceph.py @@ -53,11 +53,15 @@ def deploy(): 'role': 'controller', })[0] + managed_apt = vr.create( + 'managed_apt1', 'templates/mos_repos.yaml', + {'node': first_node.name, 'index': 0})[-1] + keys.connect(ceph_mon, {}) first_node.connect(ceph_mon, {'ip': ['ip', 'public_vip', 'management_vip']}) library.connect(ceph_mon, {'puppet_modules': 'puppet_modules'}) - + managed_apt.connect(ceph_mon, {}) if __name__ == '__main__': deploy() diff --git a/resources/apt_repo/actions/remove.yaml b/resources/apt_repo/actions/remove.yaml new file mode 100644 index 00000000..55de2217 --- /dev/null +++ b/resources/apt_repo/actions/remove.yaml @@ -0,0 +1,9 @@ +- hosts: [{{host}}] + sudo: yes + tasks: + - shell: rm -f {{item}} + with_items: + - /etc/apt/sources.list.d/{{name}}.list + - /etc/apt/preferences.d/{{name}}.pref + - shell: apt-get update + when: {{validate_integrity}} diff --git a/resources/apt_repo/actions/run.yaml b/resources/apt_repo/actions/run.yaml index cb71d641..7897049a 100644 --- a/resources/apt_repo/actions/run.yaml +++ b/resources/apt_repo/actions/run.yaml @@ -1,9 +1,11 @@ - hosts: [{{host}}] sudo: yes tasks: - - apt_repository: repo={{repo}} validate_certs=no - - file: path=/etc/apt/preferences.d/{{name}}.pref state=touch + - template: + src: {{templates_dir}}/source + dest: /etc/apt/sources.list.d/{{name}}.list - template: src: {{templates_dir}}/preferences dest: /etc/apt/preferences.d/{{name}}.pref - shell: apt-get update + when: {{validate_integrity}} diff --git a/resources/apt_repo/meta.yaml b/resources/apt_repo/meta.yaml index 848c40be..0f3823ce 100644 --- a/resources/apt_repo/meta.yaml +++ b/resources/apt_repo/meta.yaml @@ -18,5 +18,8 @@ input: schema: str value: pin_priority: - schema: str + schema: int value: + validate_integrity: + schema: bool + value: true diff --git a/resources/apt_repo/templates/source b/resources/apt_repo/templates/source new file mode 100644 index 00000000..2f02ce16 --- /dev/null +++ b/resources/apt_repo/templates/source @@ -0,0 +1 @@ +{{repo}} diff --git a/resources/managed_apt/actions/run.yaml b/resources/managed_apt/actions/run.yaml index e0a4a7f5..2776ef02 100644 --- a/resources/managed_apt/actions/run.yaml +++ b/resources/managed_apt/actions/run.yaml @@ -4,3 +4,4 @@ - shell: echo 'Managed by solar' > /etc/apt/sources.list when: {{ensure_other_removed}} - shell: apt-get update + when: {{ensure_other_removed}} diff --git a/templates/mos_repos.yaml b/templates/mos_repos.yaml new file mode 100644 index 00000000..dddf431e --- /dev/null +++ b/templates/mos_repos.yaml @@ -0,0 +1,43 @@ +id: mos_repos +resources: + - id: mos_holdback_{{index}} + from: resources/apt_repo + location: {{node}} + values: + name: mos-holdback + package: '*' + repo: deb http://mirror.fuel-infra.org/mos-repos/ubuntu/7.0/ mos7.0-holdback main restricted + pin: release o=Mirantis,n=mos7.0,a=mos7.0-holdback,l=mos7.0 + pin_priority: 1100 + - id: mos_security_{{index}} + from: resources/apt_repo + location: {{node}} + values: + name: mos + package: '*' + repo: deb http://mirror.fuel-infra.org/mos-repos/ubuntu/7.0/ mos7.0-security main restricted + pin: release o=Mirantis,n=mos7.0,a=mos7.0-security,l=mos7.0 + pin_priority: 1050 + - id: mos_updates_{{index}} + from: resources/apt_repo + location: {{node}} + values: + name: mos_update + package: '*' + repo: deb http://mirror.fuel-infra.org/mos-repos/ubuntu/7.0/ mos7.0-updates main restricted + pin: release o=Mirantis,a=mos7.0-updates,l=mos7.0,n=mos7.0 + pin_priority: 1050 + - id: managed_apt_{{index}} + from: resources/managed_apt + location: {{node}} + values: + names: + - mos_holdback_{{index}}::name + - mos_security_{{index}}::name + - mos_updates_{{index}}::name + repos: + - mos_holdback_{{index}}::repo + - mos_security_{{index}}::repo + - mos_updates_{{index}}::repo + ensure_other_removed: false +