diff --git a/ansible/roles/baselayout/tasks/ccache.yml b/ansible/roles/baselayout/tasks/ccache.yml deleted file mode 100644 index de8563359..000000000 --- a/ansible/roles/baselayout/tasks/ccache.yml +++ /dev/null @@ -1,125 +0,0 @@ ---- -# -# Downloads and installs ccache -# @requires: version=3.2.4 -# - -- name: "ccache : fetch samba ccache HTML page" - when: not os|startswith("aix") - # This depends on ansible being able to run curl locally, YMMV, if it doesn't - # work, try changing the local_action to a remote one: - # raw: curl -sL https://www.samba.org/ftp/ccache/ - local_action: shell curl -sL https://www.samba.org/ftp/ccache/ | sed -n -e 's/.*"ccache-\([0-9.]*\).tar.gz".*/\1/p' | tail -1 - register: ccache_html_content - -- name: "ccache : fetch tarball - aix" - when: os|startswith("aix") - shell: - chdir: "/tmp" - cmd: "curl -L -o ccache-3.7.4.tar.gz https://github.com/ccache/ccache/releases/download/v3.7.4/ccache-3.7.4.tar.gz" - -- name: "ccache : extract ccache latest version" - when: not os|startswith("aix") - set_fact: - ccache_latest: "{{ ccache_html_content.stdout }}" - -- name: "ccache : download and extract" - when: not os|startswith("aix") - unarchive: - dest: /tmp/ - remote_src: yes - src: "https://www.samba.org/ftp/ccache/ccache-{{ ccache_latest }}.tar.gz" - register: new_archive - -- name: "ccache : extract tarball - aix" - when: os|startswith("aix") - shell: - chdir: "/tmp" - cmd: "/opt/freeware/bin/tar -xzf ccache-3.7.4.tar.gz" - -- name: "ccache : prepare for compilation" - when: not os|startswith("smartos") and not os|startswith("aix") - shell: ./configure -q - args: - chdir: "/tmp/ccache-{{ ccache_latest }}" - -- name: "ccache : prepare for compilation - smartos" - when: os|startswith("smartos") - shell: bash ./configure CPPFLAGS=-std=c99 - args: - chdir: "/tmp/ccache-{{ ccache_latest }}" - -- name: "ccache : compile - aix" - when: os|startswith("aix") - shell: - chdir: "/tmp/ccache-3.7.4" - cmd: './configure CC="/opt/freeware/bin/gcc -maix64" && /opt/freeware/bin/gmake' - -- name: "ccache : compile" - when: not os|startswith("aix") - make: chdir="/tmp/ccache-{{ ccache_latest }}" - -- name: "ccache : install" - when: not os|startswith("aix") - copy: - dest: "/usr/local/bin" - mode: 0755 - remote_src: yes - src: "/tmp/ccache-{{ ccache_latest }}/ccache" - -- name: "ccache : install - create directory aix" - when: os|startswith("aix") - file: - path: /opt/ccache-3.7.4/{{ item.dest }} - state: directory - mode: '0755' - loop: - - { dest: bin } - - { dest: libexec } - -- name: "ccache : install - move file aix" - when: os|startswith("aix") - shell: - chdir: "/tmp" - cmd: "mv ccache-3.7.4/ccache /opt/ccache-3.7.4/bin" - -- name: "ccache : create symlinks" - when: not os|startswith("aix") - loop_control: - loop_var: destination - with_items: [ 'gcc', 'cc', 'g++', 'c++' ] - file: - dest: "/usr/local/bin/{{ destination }}" - src: /usr/local/bin/ccache - state: link - -- name: "ccache : create symlinks - aix" - when: os|startswith("aix") - file: - src: /opt/ccache-3.7.4/bin/ccache - dest: /opt/ccache-3.7.4/libexec/{{ item.dest }} - owner: root - group: system - state: link - loop: - - { dest: gcc } - - { dest: g++ } - - { dest: gcov } - - { dest: cpp } - - { dest: c++ } - -- name: "ccache : cleanup" - when: not os|startswith("aix") - file: path="/tmp/ccache-{{ ccache_latest }}" state=absent - -- name: "ccache : cleanup - aix tarball" - when: os|startswith("aix") - file: - path: "/tmp/ccache-3.7.4.tar.gz" - state: absent - -- name: "ccache : cleanup - aix directory" - when: os|startswith("aix") - file: - path: /tmp/ccache-3.7.4 - state: absent diff --git a/ansible/roles/baselayout/tasks/main.yml b/ansible/roles/baselayout/tasks/main.yml index d5d8a058d..272d128d5 100644 --- a/ansible/roles/baselayout/tasks/main.yml +++ b/ansible/roles/baselayout/tasks/main.yml @@ -56,17 +56,6 @@ - "{{ role_path }}/tasks/partials/repo/{{ os|stripversion }}.yml" skip: true -- name: check for a recent enough ccache - when: os in ccache_no_binpkg or 'rhel7-s390x' in inventory_hostname - stat: path="{{ binary_dest }}" - register: has_ccache - -- name: check for ccache aix - when: os|startswith("aix") - stat: - path: /opt/ccache-3.7.4/bin/ccache - register: has_ccache - - name: check for a recent enough git when: os in git_no_binpkg stat: path="{{ binary_dest }}" @@ -107,20 +96,6 @@ - "{{ packages[os|stripversion]|default('[]') }}" - "{{ common_packages|default('[]') }}" -- name: Check whether /etc/paths contains "/usr/local/opt/ccache/libexec" (macos) - when: os|startswith("macos") - command: grep -Fxq "/usr/local/opt/ccache/libexec" /etc/paths - register: ccache_mac - check_mode: no - ignore_errors: yes - changed_when: no - -- name: add ccache to the path (macos) - when: os|startswith("macos") and ccache_mac.rc == 1 - lineinfile: dest=/etc/paths - insertbefore=BOF - line='/usr/local/opt/ccache/libexec' - - name: centos7_ppc64 | update package alternatives when: os == "centos7" and arch == "ppc64" alternatives: @@ -213,23 +188,15 @@ - curl_64 - name: run ccache installer - when: os == "rhel7" and arch == "s390x" and not has_ccache.stat.exists - include: ccache.yml - static: false - vars: - - version: 3.3.3 - -- name: run ccache installer - when: os in ccache_no_binpkg and not has_ccache.stat.exists - include: ccache.yml - static: false - -- name: run ccache installer - when: os|startswith("aix") and not has_ccache.stat.exists - include: ccache.yml - static: false - vars: - - version: 3.7.4 + include: "{{ ccache_include }}" + loop_control: + loop_var: ccache_include + with_first_found: + - files: + - "{{ role_path }}/tasks/partials/ccache/{{ os }}-{{ arch }}.yml" + - "{{ role_path }}/tasks/partials/ccache/{{ os }}.yml" + - "{{ role_path }}/tasks/partials/ccache/{{ os|stripversion }}.yml" + skip: true - name: set up ntp include: "{{ ntp_include }}" diff --git a/ansible/roles/baselayout/tasks/partials/ccache/aix.yml b/ansible/roles/baselayout/tasks/partials/ccache/aix.yml new file mode 100644 index 000000000..3b152cdee --- /dev/null +++ b/ansible/roles/baselayout/tasks/partials/ccache/aix.yml @@ -0,0 +1,70 @@ +--- +# +# Downloads and installs ccache +# + +- name: "ccache : check for a recent enough ccache" + stat: + path: "/opt/ccache-3.7.4/bin/ccache" + register: has_ccache + +- name: "ccache : fetch tarball - aix" + shell: + chdir: "/tmp" + cmd: "curl -L -o ccache-3.7.4.tar.gz https://github.com/ccache/ccache/releases/download/v3.7.4/ccache-3.7.4.tar.gz" + when: not has_ccache.stat.exists + +- name: "ccache : extract tarball - aix" + shell: + chdir: "/tmp" + cmd: "/opt/freeware/bin/tar -xzf ccache-3.7.4.tar.gz" + when: not has_ccache.stat.exists + +- name: "ccache : compile - aix" + shell: + chdir: "/tmp/ccache-3.7.4" + cmd: './configure CC="/opt/freeware/bin/gcc -maix64" && /opt/freeware/bin/gmake' + when: not has_ccache.stat.exists + +- name: "ccache : install - create directory aix" + file: + path: /opt/ccache-3.7.4/{{ item.dest }} + state: directory + mode: '0755' + loop: + - { dest: bin } + - { dest: libexec } + when: not has_ccache.stat.exists + +- name: "ccache : install - move file aix" + shell: + chdir: "/tmp" + cmd: "mv ccache-3.7.4/ccache /opt/ccache-3.7.4/bin" + when: not has_ccache.stat.exists + +- name: "ccache : create symlinks - aix" + file: + src: /opt/ccache-3.7.4/bin/ccache + dest: /opt/ccache-3.7.4/libexec/{{ item.dest }} + owner: root + group: system + state: link + loop: + - { dest: gcc } + - { dest: g++ } + - { dest: gcov } + - { dest: cpp } + - { dest: c++ } + when: not has_ccache.stat.exists + +- name: "ccache : cleanup - aix tarball" + file: + path: "/tmp/ccache-3.7.4.tar.gz" + state: absent + when: not has_ccache.stat.exists + +- name: "ccache : cleanup - aix directory" + file: + path: /tmp/ccache-3.7.4 + state: absent + when: not has_ccache.stat.exists diff --git a/ansible/roles/baselayout/tasks/partials/ccache/macos.yml b/ansible/roles/baselayout/tasks/partials/ccache/macos.yml new file mode 100644 index 000000000..f6c9377f3 --- /dev/null +++ b/ansible/roles/baselayout/tasks/partials/ccache/macos.yml @@ -0,0 +1,13 @@ +- name: "ccache : check whether /etc/paths contains '/usr/local/opt/ccache/libexec' (macos)" + command: grep -Fxq "/usr/local/opt/ccache/libexec" /etc/paths + register: ccache_mac + check_mode: no + ignore_errors: yes + changed_when: no + +- name: "ccache : add ccache to the path (macos)" + when: ccache_mac.rc == 1 + lineinfile: + dest: "etc/paths" + insertbefore: BOF + line: "usr/local/opt/ccache/libexec" diff --git a/ansible/roles/baselayout/tasks/partials/ccache/rhel7-s390x.yml b/ansible/roles/baselayout/tasks/partials/ccache/rhel7-s390x.yml new file mode 100644 index 000000000..abeee6ed4 --- /dev/null +++ b/ansible/roles/baselayout/tasks/partials/ccache/rhel7-s390x.yml @@ -0,0 +1,63 @@ +--- +# +# Downloads and installs ccache +# + +- name: "ccache : check for a recent enough ccache" + stat: + path: "/usr/local/bin/ccache" + register: has_ccache + +- name: "ccache : fetch samba ccache HTML page" + # This depends on ansible being able to run curl locally, YMMV, if it doesn't + # work, try changing the local_action to a remote one: + # raw: curl -sL https://www.samba.org/ftp/ccache/ + local_action: shell curl -sL https://www.samba.org/ftp/ccache/ | sed -n -e 's/.*"ccache-\([0-9.]*\).tar.gz".*/\1/p' | tail -1 + register: ccache_html_content + when: not has_ccache.stat.exists + +- name: "ccache : extract ccache latest version" + set_fact: + ccache_latest: "{{ ccache_html_content.stdout }}" + when: not has_ccache.stat.exists + +- name: "ccache : download and extract" + unarchive: + dest: /tmp/ + remote_src: yes + src: "https://www.samba.org/ftp/ccache/ccache-{{ ccache_latest }}.tar.gz" + register: new_archive + when: not has_ccache.stat.exists + +- name: "ccache : prepare for compilation" + shell: ./configure -q + args: + chdir: "/tmp/ccache-{{ ccache_latest }}" + when: not has_ccache.stat.exists + +- name: "ccache : compile" + make: + chdir: "tmp/ccache-{{ ccache_latest }}" + when: not has_ccache.stat.exists + +- name: "ccache : install" + copy: + dest: "/usr/local/bin" + mode: 0755 + remote_src: yes + src: "/tmp/ccache-{{ ccache_latest }}/ccache" + when: not has_ccache.stat.exists + +- name: "ccache : create symlinks" + loop_control: + loop_var: destination + with_items: [ 'gcc', 'cc', 'g++', 'c++' ] + file: + dest: "/usr/local/bin/{{ destination }}" + src: /usr/local/bin/ccache + state: link + when: not has_ccache.stat.exists + +- name: "ccache : cleanup" + file: path="/tmp/ccache-{{ ccache_latest }}" state=absent + when: not has_ccache.stat.exists diff --git a/ansible/roles/baselayout/tasks/partials/ccache/smartos17.yml b/ansible/roles/baselayout/tasks/partials/ccache/smartos17.yml new file mode 100644 index 000000000..b78c13e93 --- /dev/null +++ b/ansible/roles/baselayout/tasks/partials/ccache/smartos17.yml @@ -0,0 +1,65 @@ +--- +# +# Downloads and installs ccache +# + +- name: "ccache : check for a recent enough ccache" + stat: + path: "/usr/local/bin/ccache" + register: has_ccache + +- name: "ccache : fetch samba ccache HTML page" + # This depends on ansible being able to run curl locally, YMMV, if it doesn't + # work, try changing the local_action to a remote one: + # raw: curl -sL https://www.samba.org/ftp/ccache/ + local_action: shell curl -sL https://www.samba.org/ftp/ccache/ | sed -n -e 's/.*"ccache-\([0-9.]*\).tar.gz".*/\1/p' | tail -1 + register: ccache_html_content + when: not has_ccache.stat.exists + +- name: "ccache : extract ccache latest version" + set_fact: + ccache_latest: "{{ ccache_html_content.stdout }}" + when: not has_ccache.stat.exists + +- name: "ccache : download and extract" + unarchive: + dest: /tmp/ + remote_src: yes + src: "https://www.samba.org/ftp/ccache/ccache-{{ ccache_latest }}.tar.gz" + register: new_archive + when: not has_ccache.stat.exists + +- name: "ccache : prepare for compilation - smartos" + shell: bash ./configure CPPFLAGS=-std=c99 + args: + chdir: "/tmp/ccache-{{ ccache_latest }}" + when: not has_ccache.stat.exists + +- name: "ccache : compile" + make: + chdir: "/tmp/ccache-{{ ccache_latest }}" + when: not has_ccache.stat.exists + +- name: "ccache : install" + copy: + dest: "/usr/local/bin" + mode: 0755 + remote_src: yes + src: "/tmp/ccache-{{ ccache_latest }}/ccache" + when: not has_ccache.stat.exists + +- name: "ccache : create symlinks" + loop_control: + loop_var: destination + with_items: [ 'gcc', 'cc', 'g++', 'c++' ] + file: + dest: "/usr/local/bin/{{ destination }}" + src: /usr/local/bin/ccache + state: link + when: not has_ccache.stat.exists + +- name: "ccache : cleanup" + file: + path: "/tmp/ccache-{{ ccache_latest }}" + state: absent + when: not has_ccache.stat.exists diff --git a/ansible/roles/baselayout/vars/main.yml b/ansible/roles/baselayout/vars/main.yml index c1910720d..eec92f46b 100644 --- a/ansible/roles/baselayout/vars/main.yml +++ b/ansible/roles/baselayout/vars/main.yml @@ -4,11 +4,6 @@ # variables shared in baselayout # -binary_dest: '/usr/local/bin/ccache' - -ccache_no_binpkg: ['smartos15', 'smartos16', 'smartos17'] -ccache_version: 3.3.2 - git_no_binpkg: ['debian7'] git_version: 2.10.2