Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
Liubo/remove raw module 3.0 (#949)
Browse files Browse the repository at this point in the history
* Replace raw module to shell (#947)
  • Loading branch information
liubo0127 authored Sep 11, 2019
1 parent b947213 commit b22c98f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion roles/check_config_static/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
when: (timezone is undefined) or (timezone is defined and timezone == "")

- name: Close old SSH control master processes
raw: pkill -f "ssh.*ansible.*"
shell: pkill -f "ssh.*ansible.*"
ignore_errors: true
changed_when: false
failed_when: false
Expand Down
4 changes: 2 additions & 2 deletions roles/check_system_static/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

- name: Disk space check - Fail task when disk is full
raw: df -h . | tail -n1
shell: df -h . | tail -n1
register: disk_space_st
failed_when: " '100%' in disk_space_st.stdout "
changed_when: false
Expand Down Expand Up @@ -63,4 +63,4 @@
- name: Preflight check - Fail when Linux kernel vm.overcommit_memory parameter is set to 2
fail:
msg: "It is not recommended to set vm.overcommit_memory to 2, set it to 0 or 1."
when: vm_overcommit_memory.stdout | int == 2
when: vm_overcommit_memory.stdout | int == 2
26 changes: 12 additions & 14 deletions roles/pre-ansible/tasks/coreos.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---

- name: CoreOS | Check python executable linkage and mark .bootstrapped
raw: "{{ bootstrap_script_dir }}/pypy/bin/python --version"
shell: "{{ bootstrap_script_dir }}/pypy/bin/python --version"
register: pypy_st

- name: CoreOS - detect outbound network
raw: curl -s --connect-timeout 4 baidu.com 2>/dev/null >/dev/null; echo $?
shell: curl -s --connect-timeout 4 baidu.com 2>/dev/null >/dev/null; echo $?
changed_when: false
register: outbound_network_st

- name: CoreOS - set outbound network fact
set_fact: has_outbound_network={{ outbound_network_st.stdout.strip() == '0' }}

- name: CoreOS - detect GFW
raw: curl -s --connect-timeout 2 google.com 2>/dev/null >/dev/null; echo $?
shell: curl -s --connect-timeout 2 google.com 2>/dev/null >/dev/null; echo $?
changed_when: false
register: gfw_st

Expand All @@ -25,44 +25,42 @@
pypy_download_url: "{{ pypy_download_url_under_gfw }}"

- name: CoreOS | Create bootstrap directory
raw: sudo mkdir -p {{ bootstrap_script_dir }}
shell: sudo mkdir -p {{ bootstrap_script_dir }}

- name: CoreOS | deploy pypy -
raw: >
shell: >
http_proxy="{{ http_proxy|default('') }}"
https_proxy="{{ https_proxy|default('') }}"
no_proxy="{{ no_proxy|default('') }}"
wget -O /tmp/pypy2-v{{ pypy_version }}-linux64.tar.bz2 {{ pypy_download_url }}
when: has_outbound_network

- name: CoreOS | Extract pypy tar to tmp
raw: tar -xjf /tmp/pypy2-v{{ pypy_version }}-linux64.tar.bz2 -C /tmp
shell: tar -xjf /tmp/pypy2-v{{ pypy_version }}-linux64.tar.bz2 -C /tmp

- name: CoreOS | Move pypy source to python bootstrap directory
raw: sudo mv -n /tmp/pypy2-v{{ pypy_version }}-linux64 {{ bootstrap_script_dir }}/pypy
shell: sudo mv -n /tmp/pypy2-v{{ pypy_version }}-linux64 {{ bootstrap_script_dir }}/pypy

- name: CoreOS | Make pypy lib directory and link ncurses .so
raw: mkdir -p {{ bootstrap_script_dir }}/pypy/lib && ln -snf /lib64/libncurses.so.5.9 {{ bootstrap_script_dir }}/pypy/lib/libtinfo.so.5
shell: mkdir -p {{ bootstrap_script_dir }}/pypy/lib && ln -snf /lib64/libncurses.so.5.9 {{ bootstrap_script_dir }}/pypy/lib/libtinfo.so.5

- name: CoreOS | Add python exec script to bootstrap directory
raw: >
shell: >
printf "%s\n%s"
"#! /bin/bash"
"LD_LIBRARY_PATH={{ bootstrap_script_dir }}/pypy/lib:\$LD_LIBRARY_PATH exec {{ bootstrap_script_dir }}/pypy/bin/pypy \"\$@\""
> {{ bootstrap_script_dir }}/pypy/bin/python
- name: CoreOS | Add exec permission to python exec script
raw: chmod +x {{ bootstrap_script_dir }}/pypy/bin/python
shell: chmod +x {{ bootstrap_script_dir }}/pypy/bin/python

- name: CoreOS | Check python executable linkage and mark .bootstrapped
raw: "{{ bootstrap_script_dir }}/pypy/bin/python --version"
shell: "{{ bootstrap_script_dir }}/pypy/bin/python --version"
register: pypy_st

- name: CoreOS |


"PATH=\$PATH:{{ bin_dir }}"
> /etc/profile.d/python-path.sh

- name: CoreOS | Change permissions and ownership for opt-path.sh to run as root
raw: chmod 0755 /etc/profile.d/python-path.sh && chown root /etc/profile.d/python-path.sh
shell: chmod 0755 /etc/profile.d/python-path.sh && chown root /etc/profile.d/python-path.sh
6 changes: 3 additions & 3 deletions roles/pre-ansible/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---

- name: disk space check - fail when disk is full
raw: df -h . | tail -n1
shell: df -h . | tail -n1
register: disk_space_st
failed_when: " '100%' in disk_space_st.stdout "
changed_when: false

# Debian GNU/Linux, Ubuntu, Fedora, CentOS, CoreOS
- name: Get distro name from /etc/os-release
raw: "([ -f /etc/os-release ] && grep '^NAME=' /etc/os-release | sed s'/NAME=//' | tr -d \\\") || ([ -f /etc/redhat-release ] && cat /etc/redhat-release | cut '-d ' -f1)"
shell: "([ -f /etc/os-release ] && grep '^NAME=' /etc/os-release | sed s'/NAME=//' | tr -d \\\") || ([ -f /etc/redhat-release ] && cat /etc/redhat-release | cut '-d ' -f1)"
register: distro_st
failed_when: false
changed_when: false
Expand All @@ -18,7 +18,7 @@
distro: "{{ distro_st.stdout | trim }}"

- name: python check
raw: python --version
shell: python --version
register: py_st
failed_when: false
changed_when: false
Expand Down
4 changes: 2 additions & 2 deletions roles/pre-ansible/tasks/root_tasks.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---

- name: Debian/Ubuntu - install python
raw: sudo apt-get -y install python
shell: sudo apt-get -y install python
when:
- "'Ubuntu' in distro or 'Debian' in distro"
- "not has_python"

- name: Redhat/CentOS - install python
raw: sudo yum -y install python
shell: sudo yum -y install python
when:
- "'CentOS' in distro"
- "not has_python"
Expand Down

0 comments on commit b22c98f

Please sign in to comment.