mirror of
https://github.com/MHA-Team/PTS-Team.git
synced 2026-02-19 20:42:29 +00:00
v2.9 Ansible
This commit is contained in:
@@ -11,7 +11,7 @@ Example Playbook
|
||||
|
||||
- hosts: all
|
||||
roles:
|
||||
- role: wtanaka.gcloud_sdk
|
||||
- role: wtanaka.gcloud-sdk
|
||||
|
||||
Variables
|
||||
---------
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
---
|
||||
- include: get_key.yml
|
||||
- include_tasks: get_key.yml
|
||||
|
||||
- name: add google cloud key to apt-key
|
||||
apt_key: file=/root/A7317B0F.gpg
|
||||
become: yes
|
||||
|
||||
- name: sources.list
|
||||
template: >
|
||||
@@ -10,23 +11,26 @@
|
||||
dest=/etc/apt/sources.list.d/google-cloud-sdk.list
|
||||
force=no
|
||||
register: sources_list_result
|
||||
become: yes
|
||||
|
||||
# Install apt-transport-https
|
||||
- name: install apt-transport-https
|
||||
action: "{{backcompat_pkg_mgr}} name=apt-transport-https"
|
||||
register: result_install_transport_https
|
||||
until: result_install_transport_https|success
|
||||
until: result_install_transport_https is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
delay: 10
|
||||
become: yes
|
||||
|
||||
- name: apt-get update
|
||||
apt: update_cache=true cache_valid_time=0
|
||||
when: sources_list_result.changed
|
||||
register: result_apt_update
|
||||
until: result_apt_update|success
|
||||
until: result_apt_update is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
delay: 10
|
||||
become: yes
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
- include: get_key_sudo.yml
|
||||
- include_tasks: get_key_sudo.yml
|
||||
|
||||
- name: add google cloud key to apt-key
|
||||
apt_key: file=/root/A7317B0F.gpg
|
||||
@@ -18,7 +18,7 @@
|
||||
action: "{{backcompat_pkg_mgr}} name=apt-transport-https"
|
||||
sudo: yes
|
||||
register: result_install_transport_https
|
||||
until: result_install_transport_https|success
|
||||
until: result_install_transport_https is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -29,7 +29,7 @@
|
||||
when: sources_list_result.changed
|
||||
sudo: yes
|
||||
register: result_apt_update
|
||||
until: result_apt_update|success
|
||||
until: result_apt_update is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
- name: repo
|
||||
template: >
|
||||
src=google-cloud-sdk.repo.j2
|
||||
dest=/etc/yum.repos.d/google-cloud-sdk.repo
|
||||
force=no
|
||||
template:
|
||||
src: google-cloud-sdk.repo.j2
|
||||
dest: /etc/yum.repos.d/google-cloud-sdk.repo
|
||||
force: no
|
||||
become: yes
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
---
|
||||
- { become: yes, include: compat.yml }
|
||||
- { become: yes, include: Debian.yml, when: ansible_os_family == 'Debian' }
|
||||
- { become: yes, include: RedHat.yml, when: ansible_os_family == 'RedHat' }
|
||||
- { become: yes, include: install_package_names.yml }
|
||||
- { become: yes, include: install_additional_packages.yml }
|
||||
- include_tasks: compat.yml
|
||||
- include_tasks: Debian.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
- include_tasks: RedHat.yml
|
||||
when: ansible_os_family == 'RedHat'
|
||||
- include_tasks: install_package_names.yml
|
||||
- include_tasks: install_additional_packages.yml
|
||||
|
||||
@@ -8,13 +8,14 @@
|
||||
(apt-get update -qq && apt-get install -y python-apt)));
|
||||
fi
|
||||
register: result_python_apt
|
||||
until: result_python_apt|success
|
||||
until: result_python_apt is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
delay: 10
|
||||
when: should_run and ansible_os_family == 'Debian'
|
||||
changed_when: False
|
||||
become: yes
|
||||
|
||||
- name: install python-pycurl on ansible < 1.6.0 and ubuntu et al
|
||||
raw: >
|
||||
@@ -25,13 +26,14 @@
|
||||
(apt-get update -qq && apt-get install -y python-pycurl)));
|
||||
fi
|
||||
register: result_python_pycurl
|
||||
until: result_python_pycurl|success
|
||||
until: result_python_pycurl is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
delay: 10
|
||||
when: should_run and ansible_os_family == 'Debian'
|
||||
changed_when: False
|
||||
become: yes
|
||||
|
||||
- name: install python2-yum on ansible <=1.9.2/fedora 24
|
||||
raw: >
|
||||
@@ -40,13 +42,14 @@
|
||||
(> /dev/null command -v yum && ! > /dev/null command -v dnf && yum install -y python2-yum);
|
||||
fi
|
||||
register: result_python_yum
|
||||
until: result_python_yum|success
|
||||
until: result_python_yum is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
delay: 10
|
||||
when: should_run and ansible_os_family == 'RedHat'
|
||||
changed_when: False
|
||||
become: yes
|
||||
|
||||
- name: install python2-dnf on ansible 2.1/fedora 24
|
||||
raw: >
|
||||
@@ -55,13 +58,14 @@
|
||||
(> /dev/null command -v dnf && dnf install -y python2-dnf);
|
||||
fi
|
||||
register: result_python_dnf
|
||||
until: result_python_dnf|success
|
||||
until: result_python_dnf is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
delay: 10
|
||||
when: should_run and ansible_os_family == 'RedHat'
|
||||
changed_when: False
|
||||
become: yes
|
||||
|
||||
# Set backcompat_pkg_mgr for versions of ansible that set
|
||||
# ansible_pkg_mgr to yum instead of dnf
|
||||
@@ -71,14 +75,15 @@
|
||||
ignore_errors: True
|
||||
when: should_run and ansible_os_family == 'RedHat'
|
||||
changed_when: False
|
||||
become: yes
|
||||
|
||||
- set_fact:
|
||||
backcompat_pkg_mgr: 'dnf'
|
||||
when: should_run and ansible_os_family == 'RedHat' and dnf_result|success
|
||||
when: should_run and ansible_os_family == 'RedHat' and dnf_result is success
|
||||
|
||||
- set_fact:
|
||||
backcompat_pkg_mgr: '{{ansible_pkg_mgr}}'
|
||||
when: should_run and ansible_os_family == 'RedHat' and dnf_result|failed
|
||||
when: should_run and ansible_os_family == 'RedHat' and dnf_result is failed
|
||||
|
||||
- set_fact:
|
||||
backcompat_pkg_mgr: '{{ansible_pkg_mgr}}'
|
||||
@@ -100,12 +105,13 @@
|
||||
ignore_errors: True
|
||||
changed_when: False
|
||||
when: should_run
|
||||
become: yes
|
||||
|
||||
# Install wget due to https://github.com/ansible/ansible/issues/12161
|
||||
- name: install wget with non-dnf
|
||||
action: "{{backcompat_pkg_mgr}} name=wget"
|
||||
register: result_wget
|
||||
until: result_wget|success
|
||||
until: result_wget is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -113,28 +119,20 @@
|
||||
when: >
|
||||
should_run and
|
||||
(backcompat_pkg_mgr == "yum" or backcompat_pkg_mgr == "apt")
|
||||
and wget_result|failed
|
||||
and wget_result is failed
|
||||
become: yes
|
||||
|
||||
# Install wget due to https://github.com/ansible/ansible/issues/12161
|
||||
# Use command since dnf was only added as a module in ansible 1.9.0
|
||||
- name: install wget with dnf
|
||||
command: dnf install -y wget
|
||||
register: result_wget_dnf
|
||||
until: result_wget_dnf|success
|
||||
until: result_wget_dnf is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
delay: 10
|
||||
args:
|
||||
creates: /usr/bin/wget
|
||||
when: should_run and backcompat_pkg_mgr == "dnf" and wget_result|failed
|
||||
|
||||
- name: Remove wheezy-updates
|
||||
command: sed -i.old -e 's/\(.*deb.debian.org\/debian wheezy-updates\)/#\1/' /etc/apt/sources.list
|
||||
changed_when: False
|
||||
when: should_run and ansible_os_family == 'Debian'
|
||||
|
||||
- name: Switch debian wheezy to archives
|
||||
command: sed -i.old -e 's/deb.debian.org\/debian wheezy/archive.debian.org\/debian wheezy/' /etc/apt/sources.list
|
||||
changed_when: False
|
||||
when: should_run and ansible_os_family == 'Debian'
|
||||
when: should_run and backcompat_pkg_mgr == "dnf" and wget_result is failed
|
||||
become: yes
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
(apt-get update -qq && apt-get install -y python-apt)));
|
||||
fi
|
||||
register: result_python_apt
|
||||
until: result_python_apt|success
|
||||
until: result_python_apt is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -27,7 +27,7 @@
|
||||
(apt-get update -qq && apt-get install -y python-pycurl)));
|
||||
fi
|
||||
register: result_python_pycurl
|
||||
until: result_python_pycurl|success
|
||||
until: result_python_pycurl is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -43,7 +43,7 @@
|
||||
(> /dev/null command -v yum && ! > /dev/null command -v dnf && yum install -y python2-yum);
|
||||
fi
|
||||
register: result_python_yum
|
||||
until: result_python_yum|success
|
||||
until: result_python_yum is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -59,7 +59,7 @@
|
||||
(> /dev/null command -v dnf && dnf install -y python2-dnf);
|
||||
fi
|
||||
register: result_python_dnf
|
||||
until: result_python_dnf|success
|
||||
until: result_python_dnf is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -78,11 +78,11 @@
|
||||
|
||||
- set_fact:
|
||||
backcompat_pkg_mgr: 'dnf'
|
||||
when: should_run and ansible_os_family == 'RedHat' and dnf_result|success
|
||||
when: should_run and ansible_os_family == 'RedHat' and dnf_result is success
|
||||
|
||||
- set_fact:
|
||||
backcompat_pkg_mgr: '{{ansible_pkg_mgr}}'
|
||||
when: should_run and ansible_os_family == 'RedHat' and dnf_result|failed
|
||||
when: should_run and ansible_os_family == 'RedHat' and dnf_result is failed
|
||||
|
||||
- set_fact:
|
||||
backcompat_pkg_mgr: '{{ansible_pkg_mgr}}'
|
||||
@@ -109,7 +109,7 @@
|
||||
- name: install wget with non-dnf
|
||||
action: "{{backcompat_pkg_mgr}} name=wget"
|
||||
register: result_wget
|
||||
until: result_wget|success
|
||||
until: result_wget is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -118,14 +118,14 @@
|
||||
when: >
|
||||
should_run and
|
||||
(backcompat_pkg_mgr == "yum" or backcompat_pkg_mgr == "apt")
|
||||
and wget_result|failed
|
||||
and wget_result is failed
|
||||
|
||||
# Install wget due to https://github.com/ansible/ansible/issues/12161
|
||||
# Use command since dnf was only added as a module in ansible 1.9.0
|
||||
- name: install wget with dnf
|
||||
command: dnf install -y wget
|
||||
register: result_wget_dnf
|
||||
until: result_wget_dnf|success
|
||||
until: result_wget_dnf is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -133,16 +133,4 @@
|
||||
args:
|
||||
creates: /usr/bin/wget
|
||||
sudo: yes
|
||||
when: should_run and backcompat_pkg_mgr == "dnf" and wget_result|failed
|
||||
|
||||
- name: Remove wheezy-updates
|
||||
command: sed -i.old -e 's/\(.*deb.debian.org\/debian wheezy-updates\)/#\1/' /etc/apt/sources.list
|
||||
changed_when: False
|
||||
sudo: yes
|
||||
when: should_run and ansible_os_family == 'Debian'
|
||||
|
||||
- name: Switch debian wheezy to archives
|
||||
command: sed -i.old -e 's/deb.debian.org\/debian wheezy/archive.debian.org\/debian wheezy/' /etc/apt/sources.list
|
||||
changed_when: False
|
||||
sudo: yes
|
||||
when: should_run and ansible_os_family == 'Debian'
|
||||
when: should_run and backcompat_pkg_mgr == "dnf" and wget_result is failed
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
args:
|
||||
creates: /root/A7317B0F.gpg
|
||||
register: result_download
|
||||
until: result_download|success
|
||||
until: result_download is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
delay: 10
|
||||
become: yes
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
creates: /root/A7317B0F.gpg
|
||||
sudo: yes
|
||||
register: result_download
|
||||
until: result_download|success
|
||||
until: result_download is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
- name: install {{gcloud_sdk_additional_package_names | join(' ')}} with default package manager
|
||||
action: "{{backcompat_pkg_mgr}} name={{item}}"
|
||||
register: result_install_additional
|
||||
until: result_install_additional|success
|
||||
until: result_install_additional is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -11,6 +11,7 @@
|
||||
gcloud_sdk_additional_package_names is defined and
|
||||
(backcompat_pkg_mgr == "yum" or backcompat_pkg_mgr == "apt")
|
||||
with_items: "{{ gcloud_sdk_additional_package_names }}"
|
||||
become: yes
|
||||
|
||||
# Handle dnf case for Fedora
|
||||
- name: "check if {{gcloud_sdk_additional_package_names | join(' ')}} exists"
|
||||
@@ -19,16 +20,18 @@
|
||||
ignore_errors: True
|
||||
register: package_exists_result
|
||||
when: gcloud_sdk_additional_package_names is defined and backcompat_pkg_mgr == "dnf"
|
||||
become: yes
|
||||
|
||||
# Use command since dnf was only added as a module in ansible 1.9.0
|
||||
- name: install {{gcloud_sdk_additional_package_names | join (' ')}} with dnf
|
||||
command: dnf install -y {{gcloud_sdk_additional_package_names | join(' ')}}
|
||||
register: result_install_additional_dnf
|
||||
until: result_install_additional_dnf|success
|
||||
until: result_install_additional_dnf is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
delay: 10
|
||||
when: >
|
||||
gcloud_sdk_additional_package_names is defined and backcompat_pkg_mgr == "dnf" and
|
||||
package_exists_result|failed
|
||||
package_exists_result is failed
|
||||
become: yes
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
action: "{{backcompat_pkg_mgr}} name={{item}}"
|
||||
sudo: yes
|
||||
register: result_install_additional
|
||||
until: result_install_additional|success
|
||||
until: result_install_additional is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -26,11 +26,11 @@
|
||||
command: dnf install -y {{gcloud_sdk_additional_package_names | join(' ')}}
|
||||
sudo: yes
|
||||
register: result_install_additional_dnf
|
||||
until: result_install_additional_dnf|success
|
||||
until: result_install_additional_dnf is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
delay: 10
|
||||
when: >
|
||||
gcloud_sdk_additional_package_names is defined and backcompat_pkg_mgr == "dnf" and
|
||||
package_exists_result|failed
|
||||
package_exists_result is failed
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
- name: install {{package_names | join(' ')}} with default package manager
|
||||
action: "{{backcompat_pkg_mgr}} name={{item}}"
|
||||
register: result_default
|
||||
until: result_default|success
|
||||
until: result_default is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -13,6 +13,7 @@
|
||||
package_names and
|
||||
(backcompat_pkg_mgr == "yum" or backcompat_pkg_mgr == "apt")
|
||||
with_items: "{{ package_names }}"
|
||||
become: yes
|
||||
|
||||
# Handle dnf case for Fedora
|
||||
- name: "check if {{package_names | join(' ')}} exists"
|
||||
@@ -25,12 +26,13 @@
|
||||
package_names is defined and
|
||||
package_names and
|
||||
backcompat_pkg_mgr == "dnf"
|
||||
become: yes
|
||||
|
||||
# Use command since dnf was only added as a module in ansible 1.9.0
|
||||
- name: install {{package_names | join (' ')}} with dnf
|
||||
command: dnf install -y {{package_names | join(' ')}}
|
||||
register: result_dnf
|
||||
until: result_dnf|success
|
||||
until: result_dnf is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -40,4 +42,5 @@
|
||||
package_names is defined and
|
||||
package_names and
|
||||
backcompat_pkg_mgr == "dnf" and
|
||||
package_exists_result|failed
|
||||
package_exists_result is failed
|
||||
become: yes
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
action: "{{backcompat_pkg_mgr}} name={{item}}"
|
||||
sudo: yes
|
||||
register: result_default
|
||||
until: result_default|success
|
||||
until: result_default is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -32,7 +32,7 @@
|
||||
command: dnf install -y {{package_names | join(' ')}}
|
||||
sudo: yes
|
||||
register: result_dnf
|
||||
until: result_dnf|success
|
||||
until: result_dnf is success
|
||||
# Workaround https://github.com/ansible/ansible/issues/16868 and
|
||||
# increase default retry count
|
||||
retries: 20
|
||||
@@ -42,4 +42,4 @@
|
||||
package_names is defined and
|
||||
package_names and
|
||||
backcompat_pkg_mgr == "dnf" and
|
||||
package_exists_result|failed
|
||||
package_exists_result is failed
|
||||
|
||||
@@ -7,7 +7,20 @@
|
||||
|
||||
- name: set should_run fact
|
||||
set_fact:
|
||||
should_run: "{{installed|failed or not gcloud_sdk_should_shortcircuit}}"
|
||||
should_run: True
|
||||
when: installed is failed or not gcloud_sdk_should_shortcircuit
|
||||
|
||||
- include_vars: "{{item}}"
|
||||
with_first_found:
|
||||
- "../vars/{{ansible_distribution}}-{{ansible_distribution_version}}.yml"
|
||||
- "../vars/{{ansible_distribution}}-{{ansible_distribution_major_version}}.yml"
|
||||
- "../vars/{{ansible_distribution}}.yml"
|
||||
- "../vars/{{ansible_os_family}}.yml"
|
||||
- "../vars/default.yml"
|
||||
|
||||
- include_tasks: sudo.yml
|
||||
when: ansible_version is defined and ansible_version.major < 2
|
||||
|
||||
- include_tasks: become.yml
|
||||
when: ansible_version is defined and ansible_version.major >= 2
|
||||
|
||||
- include: include_vars.yml
|
||||
- include: sudoorbecome.yml
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
- include: compat_sudo.yml
|
||||
- include: Debian_sudo.yml
|
||||
- include_tasks: compat_sudo.yml
|
||||
- include_tasks: Debian_sudo.yml
|
||||
when: ansible_os_family == 'Debian'
|
||||
- include: RedHat_sudo.yml
|
||||
- include_tasks: RedHat_sudo.yml
|
||||
when: ansible_os_family == 'RedHat'
|
||||
- include: install_package_names_sudo.yml
|
||||
- include: install_additional_packages_sudo.yml
|
||||
- include_tasks: install_package_names_sudo.yml
|
||||
- include_tasks: install_additional_packages_sudo.yml
|
||||
|
||||
Reference in New Issue
Block a user