From: David Galloway Date: Thu, 19 Oct 2017 13:35:10 +0000 (-0400) Subject: ansible: Bring ceph-build playbooks up to date with prado X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=33e52e452d74fa385c1d4cc4c23573e38d13abb2;p=ceph-build.git ansible: Bring ceph-build playbooks up to date with prado The playbooks on prado.ceph.com have been manually manipulated a few times but didn't get updated in ceph-build.git. This commit mainly includes: - Support for multiple Jenkins masters - Using Google DNS instead of OVH's (due to random DNS failures) Signed-off-by: David Galloway --- diff --git a/ansible/slave.yml b/ansible/slave.yml index 3311457c..f8357647 100644 --- a/ansible/slave.yml +++ b/ansible/slave.yml @@ -9,11 +9,46 @@ - api_user: 'ceph-jenkins' - token: '{{ token }}' - api_uri: 'https://jenkins.ceph.com' + - jenkins_credentials_uuid: '39fa150b-b2a1-416e-b334-29a9a2c0b32d' - nodename: '{{ nodename }}' - labels: '{{ labels }}' - use_jnlp: false tasks: + - name: uninstall resolvconf on Ubuntu to manually manage resolv.conf + apt: + name: resolvconf + state: absent + when: ansible_os_family == "Debian" + + - name: check for NetworkManager conf + stat: + path: /etc/NetworkManager/NetworkManager.conf + register: nm_conf + + - name: tell NetworkManager to leave resolv.conf alone on CentOS + lineinfile: + dest: /etc/NetworkManager/NetworkManager.conf + regexp: '^dns=' + line: 'dns=none' + state: present + when: ansible_os_family == "RedHat" and nm_conf.stat.exists + + - name: tell dhclient to leave resolv.conf alone on Ubuntu + lineinfile: + dest: /etc/dhcp/dhclient.conf + regexp: 'prepend domain-name-servers' + line: 'supersede domain-name-servers 8.8.8.8;' + state: present + when: ansible_os_family == "Debian" + + - name: use Google DNS for name resolution + lineinfile: + dest: /etc/resolv.conf + regexp: '^nameserver' + line: 'nameserver 8.8.8.8' + state: present + - name: create a {{ jenkins_user }} user user: name={{ jenkins_user }} comment="Jenkins Build Slave User" @@ -241,7 +276,7 @@ name: "{{ ansible_default_ipv4.address }}+{{ nodename }}" labels: "{{ labels }}" host: "{{ ansible_default_ipv4.address }}" - credentialsId: '39fa150b-b2a1-416e-b334-29a9a2c0b32d' + credentialsId: "{{ jenkins_credentials_uuid }}" remoteFS: '/home/{{ jenkins_user }}/build' executors: '{{ executors|default(1) }}' exclusive: true @@ -258,7 +293,7 @@ name: "{{ ansible_default_ipv4.address }}+{{ nodename }}" labels: "{{ labels }}" host: "{{ ansible_default_ipv4.address }}" - credentialsId: '39fa150b-b2a1-416e-b334-29a9a2c0b32d' + credentialsId: "{{ jenkins_credentials_uuid }}" launcher: 'hudson.slaves.JNLPLauncher' remoteFS: '/home/{{ jenkins_user }}/build' # XXX this should be configurable, not all nodes should have one executor diff --git a/ansible/slave_libvirt.yml b/ansible/slave_libvirt.yml index 64f12e0e..a8f64c55 100644 --- a/ansible/slave_libvirt.yml +++ b/ansible/slave_libvirt.yml @@ -9,11 +9,45 @@ - api_user: 'ceph-jenkins' - token: '{{ token }}' - api_uri: 'https://jenkins.ceph.com' + - jenkins_credentials_uuid: '39fa150b-b2a1-416e-b334-29a9a2c0b32d' - nodename: '{{ nodename }}' - labels: '{{ labels }}' - use_jnlp: false tasks: + - name: uninstall resolvconf on Ubuntu to manually manage resolv.conf + apt: + name: resolvconf + state: absent + when: ansible_os_family == "Debian" + + - name: check for NetworkManager conf + stat: + path: /etc/NetworkManager/NetworkManager.conf + register: nm_conf + + - name: tell NetworkManager to leave resolv.conf alone on CentOS + lineinfile: + dest: /etc/NetworkManager/NetworkManager.conf + regexp: '^dns=' + line: 'dns=none' + state: present + when: ansible_os_family == "RedHat" and nm_conf.stat.exists + + - name: tell dhclient to leave resolv.conf alone on Ubuntu + lineinfile: + dest: /etc/dhcp/dhclient.conf + regexp: 'prepend domain-name-servers' + line: 'supersede domain-name-servers 8.8.8.8;' + state: present + when: ansible_os_family == "Debian" + + - name: use Google DNS for name resolution + lineinfile: + dest: /etc/resolv.conf + regexp: '^nameserver' + line: 'nameserver 8.8.8.8' + state: present # vagrant doesn't have repositories, this chacra repo will be better to have # around and can get updates as soon as a new vagrant version is published via @@ -54,7 +88,7 @@ - set_fact: jenkins_group: 'libvirt' - when: ansible_distribution_version == '16.10' + when: ansible_distribution_version == '17.04' - name: create a {{ jenkins_user }} user user: @@ -137,13 +171,13 @@ when: ansible_distribution_release in ['precise', 'trusty', 'wheezy', 'jessie'] - - name: Install default openjdk for Xenial only + - name: Install default openjdk for Xenial or Zesty apt: name={{ item }} state=present with_items: - default-jdk - default-jre when: - ansible_distribution_release == 'xenial' + ansible_distribution_release in ['xenial', 'zesty'] - name: correct java version selected alternatives: name=java path=/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java @@ -231,7 +265,7 @@ name: "{{ ansible_default_ipv4.address }}+{{ nodename }}" labels: "{{ labels }}" host: "{{ ansible_default_ipv4.address }}" - credentialsId: '39fa150b-b2a1-416e-b334-29a9a2c0b32d' + credentialsId: "{{ jenkins_credentials_uuid }}" remoteFS: '/home/{{ jenkins_user }}/build' executors: '{{ executors|default(1) }}' exclusive: true @@ -248,7 +282,7 @@ name: "{{ ansible_default_ipv4.address }}+{{ nodename }}" labels: "{{ labels }}" host: "{{ ansible_default_ipv4.address }}" - credentialsId: '39fa150b-b2a1-416e-b334-29a9a2c0b32d' + credentialsId: "{{ jenkins_credentials_uuid }}" launcher: 'hudson.slaves.JNLPLauncher' remoteFS: '/home/{{ jenkins_user }}/build' # XXX this should be configurable, not all nodes should have one executor