From nobody Sat Jul 5 16:00:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1521473423268983.614263317147; Mon, 19 Mar 2018 08:30:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB4F681F01; Mon, 19 Mar 2018 15:30:20 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9172EBA85; Mon, 19 Mar 2018 15:30:20 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E46484CA9C; Mon, 19 Mar 2018 15:30:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2JFU7Fl015218 for ; Mon, 19 Mar 2018 11:30:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 58A6C10B0F20; Mon, 19 Mar 2018 15:30:07 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 001A710B2B27 for ; Mon, 19 Mar 2018 15:30:05 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Mon, 19 Mar 2018 16:29:56 +0100 Message-Id: <20180319152957.4951-3-abologna@redhat.com> In-Reply-To: <20180319152957.4951-1-abologna@redhat.com> References: <20180319152957.4951-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [jenkins-ci PATCH 2/3] guests: Factor out user creation X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 19 Mar 2018 15:30:22 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Some steps involved in creating the user account are the same regardless of flavor, and more common steps will be introduced later on, so it makes sense to have them all in the same place instead of duplicating them. Signed-off-by: Andrea Bolognani Reviewed-by: Daniel P. Berrang=C3=A9 --- guests/site.yml | 6 +----- guests/tasks/jenkins.yml | 6 ------ guests/tasks/test.yml | 21 --------------------- guests/tasks/user.yml | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 32 deletions(-) delete mode 100644 guests/tasks/test.yml create mode 100644 guests/tasks/user.yml diff --git a/guests/site.yml b/guests/site.yml index cb4ec0e..5f69cfd 100644 --- a/guests/site.yml +++ b/guests/site.yml @@ -17,6 +17,7 @@ # Prepare the base environment - include: tasks/base.yml - include: tasks/compat.yml + - include: tasks/user.yml =20 # Install build dependencies for each project - include: tasks/packages.yml @@ -34,8 +35,3 @@ - projects is defined # jenkins is a pseudo-project - ( 'jenkins' in projects ) - - # Configure the test environment - - include: tasks/test.yml - when: - - flavor =3D=3D 'test' diff --git a/guests/tasks/jenkins.yml b/guests/tasks/jenkins.yml index 9bb150b..94c2404 100644 --- a/guests/tasks/jenkins.yml +++ b/guests/tasks/jenkins.yml @@ -7,12 +7,6 @@ set_fact: jenkins_secret: '{{ vault.jenkins_secrets[inventory_hostname] }}' =20 -- name: Create Jenkins user account - user: - name: jenkins - comment: Jenkins - password: '*' - - name: Download Jenkins agent get_url: url: https://ci.centos.org/jnlpJars/slave.jar diff --git a/guests/tasks/test.yml b/guests/tasks/test.yml deleted file mode 100644 index 10146b9..0000000 --- a/guests/tasks/test.yml +++ /dev/null @@ -1,21 +0,0 @@ ---- -- name: Create test user account - user: - name: test - comment: test - password: $6$xSlfvkcsDgPmRAMX$mFh9qRmFFW9cyW1n5/jeHvq4OmJA8WzSD70Mfis3= VHc3Z5imZeiQAg9VNL4sFEtmDy/siU3nJL.QeAapCgfL20 - shell: '{{ bash }}' - -- name: Configure ssh access for the test user - authorized_key: - user: test - key: '{{ lookup("file", lookup("env", "HOME") + "/.ssh/id_rsa.pub") }}' - state: present - -- name: Grant passwordless sudo access to the test user - lineinfile: - path: '{{ sudoers }}' - line: 'test ALL=3D(ALL) NOPASSWD: ALL' - state: present - backup: yes - validate: 'visudo -cf %s' diff --git a/guests/tasks/user.yml b/guests/tasks/user.yml new file mode 100644 index 0000000..781c3d4 --- /dev/null +++ b/guests/tasks/user.yml @@ -0,0 +1,32 @@ +--- +- name: '{{ flavor }}: Create user account' + user: + name: '{{ flavor }}' + comment: '{{ flavor }}' + password: '*' + shell: '{{ bash }}' + +- name: '{{ flavor }}: Set password' + user: + name: '{{ flavor }}' + password: '$6$xSlfvkcsDgPmRAMX$mFh9qRmFFW9cyW1n5/jeHvq4OmJA8WzSD70Mfis= 3VHc3Z5imZeiQAg9VNL4sFEtmDy/siU3nJL.QeAapCgfL20' + when: + - flavor =3D=3D 'test' + +- name: '{{ flavor }}: Configure ssh access' + authorized_key: + user: '{{ flavor }}' + key: '{{ lookup("file", lookup("env", "HOME") + "/.ssh/id_rsa.pub") }}' + state: present + when: + - flavor =3D=3D 'test' + +- name: '{{ flavor }}: Grant passwordless sudo access' + lineinfile: + path: '{{ sudoers }}' + line: '{{ flavor }} ALL=3D(ALL) NOPASSWD: ALL' + state: present + backup: yes + validate: 'visudo -cf %s' + when: + - flavor =3D=3D 'test' --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list