From fcc4d8d4f5aadccb91fb5f4868e5cd6142e0ae3e Mon Sep 17 00:00:00 2001 From: Dmitry Shulyak Date: Thu, 15 Oct 2015 17:50:31 +0300 Subject: [PATCH] Add apt_repo resource and managed_apt resources apt_repo used to describe single repository, supports pinning managed_apt used to cleanup other repos, and ensure that we are using only one --- resources/apt_repo/actions/run.yaml | 9 +++++++++ resources/apt_repo/meta.yaml | 22 ++++++++++++++++++++++ resources/apt_repo/templates/preferences | 3 +++ resources/managed_apt/actions/run.yaml | 6 ++++++ resources/managed_apt/meta.yaml | 17 +++++++++++++++++ 5 files changed, 57 insertions(+) create mode 100644 resources/apt_repo/actions/run.yaml create mode 100644 resources/apt_repo/meta.yaml create mode 100644 resources/apt_repo/templates/preferences create mode 100644 resources/managed_apt/actions/run.yaml create mode 100644 resources/managed_apt/meta.yaml diff --git a/resources/apt_repo/actions/run.yaml b/resources/apt_repo/actions/run.yaml new file mode 100644 index 0000000..cb71d64 --- /dev/null +++ b/resources/apt_repo/actions/run.yaml @@ -0,0 +1,9 @@ +- 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}}/preferences + dest: /etc/apt/preferences.d/{{name}}.pref + - shell: apt-get update diff --git a/resources/apt_repo/meta.yaml b/resources/apt_repo/meta.yaml new file mode 100644 index 0000000..848c40b --- /dev/null +++ b/resources/apt_repo/meta.yaml @@ -0,0 +1,22 @@ +id: apt_repo +handler: ansible +version: 1.0.0 +input: + ip: + schema: str! + value: + repo: + schema: str! + value: + name: + schema: str! + value: + package: + schema: str + value: '*' + pin: + schema: str + value: + pin_priority: + schema: str + value: diff --git a/resources/apt_repo/templates/preferences b/resources/apt_repo/templates/preferences new file mode 100644 index 0000000..b8dfa30 --- /dev/null +++ b/resources/apt_repo/templates/preferences @@ -0,0 +1,3 @@ +Package: {{package}} +Pin: {{pin}} +Pin-Priority: {{pin_priority}} diff --git a/resources/managed_apt/actions/run.yaml b/resources/managed_apt/actions/run.yaml new file mode 100644 index 0000000..e0a4a7f --- /dev/null +++ b/resources/managed_apt/actions/run.yaml @@ -0,0 +1,6 @@ +- hosts: [{{host}}] + sudo: yes + tasks: + - shell: echo 'Managed by solar' > /etc/apt/sources.list + when: {{ensure_other_removed}} + - shell: apt-get update diff --git a/resources/managed_apt/meta.yaml b/resources/managed_apt/meta.yaml new file mode 100644 index 0000000..482bca4 --- /dev/null +++ b/resources/managed_apt/meta.yaml @@ -0,0 +1,17 @@ +# This resource will clean +id: apt_repo_manager +handler: ansible +version: 1.0.0 +input: + ip: + schema: str! + value: + repos: + schema: [str!] + value: + names: + schema: [str!] + value: + ensure_other_removed: + schema: bool + value: true