[jenkins-ci PATCH 2/3] guests: Factor out user creation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <abologna@xxxxxxxxxx>
---
 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
 
     # 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 == '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] }}'
 
-- 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/jeHvq4OmJA8WzSD70Mfis3VHc3Z5imZeiQAg9VNL4sFEtmDy/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=(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/jeHvq4OmJA8WzSD70Mfis3VHc3Z5imZeiQAg9VNL4sFEtmDy/siU3nJL.QeAapCgfL20'
+  when:
+    - flavor == 'test'
+
+- name: '{{ flavor }}: Configure ssh access'
+  authorized_key:
+    user: '{{ flavor }}'
+    key: '{{ lookup("file", lookup("env", "HOME") + "/.ssh/id_rsa.pub") }}'
+    state: present
+  when:
+    - flavor == 'test'
+
+- name: '{{ flavor }}: Grant passwordless sudo access'
+  lineinfile:
+    path: '{{ sudoers }}'
+    line: '{{ flavor }} ALL=(ALL) NOPASSWD: ALL'
+    state: present
+    backup: yes
+    validate: 'visudo -cf %s'
+  when:
+    - flavor == 'test'
-- 
2.14.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux