split ansible role

This commit is contained in:
Antoine 2020-02-18 08:09:23 +01:00
parent 0c6bf50322
commit 4c9a74b725
8 changed files with 44 additions and 40 deletions

View File

@ -14,4 +14,5 @@
fail_msg: "Pass param ssh_pub, generated_user and generated_group to launch this playbook"
roles:
- prepare
- setup

View File

@ -1,29 +1,7 @@
---
# setup gentoo
- name: "Ensure group {{ generated_group }} exists"
group:
name: "{{ generated_group }}"
- name: "create {{ generated_user }} user and {{ generated_group }} group"
user:
name: "{{ generated_user }}"
comment: "Login user generate by ansible"
group: "{{ generated_group }}"
- name: "copy ssh key to {{ user_home }}/.ssh/authorized_keys"
lineinfile:
path: "{{ user_home }}/.ssh/authorized_keys"
line: "{{ ssh_pub }}"
create: yes
owner: "{{ generated_user }}"
group: "{{ generated_user }}"
mode: '0600'
- name: Ensure SELinux is set to permissive mode
lineinfile:
path: /etc/selinux/config
regexp: '^SELINUX='
line: SELINUX=permissive
- import_tasks: partition.yml
#- import_tasks: users.yml
#- import_tasks: security.yml

View File

@ -1,19 +1,12 @@
---
# partition disk to install gentoo
- name: "Create a new primary partition with a size of 1GiB"
parted:
device: /dev/sdb
number: 1
state: present
part_end: 1GiB
- name: "Create a new primary partition for LVM"
parted:
device: /dev/sdb
number: 2
device: /dev/sda
name: "root"
label: gpt
number: 1
flags: [ lvm ]
state: present
part_start: 1GiB

View File

@ -0,0 +1,18 @@
---
# setup gentoo
- name: "copy ssh key to {{ user_home }}/.ssh/authorized_keys"
lineinfile:
path: "{{ user_home }}/.ssh/authorized_keys"
line: "{{ ssh_pub }}"
create: yes
owner: "{{ generated_user }}"
group: "{{ generated_user }}"
mode: '0600'
- name: Ensure SELinux is set to permissive mode
lineinfile:
path: /etc/selinux/config
regexp: '^SELINUX='
line: SELINUX=permissive

View File

@ -0,0 +1,13 @@
---
# create user and group
- name: "Ensure group {{ generated_group }} exists"
group:
name: "{{ generated_group }}"
- name: "create {{ generated_user }} user and {{ generated_group }} group"
user:
name: "{{ generated_user }}"
comment: "Login user generate by ansible"
group: "{{ generated_group }}"

View File

@ -0,0 +1,5 @@
#!/bin/bash
# run playbook on aready running qemu vm
ansible-playbook -i inventory_test.ini playbook.yml --extra-vars "ssh_pub=$(cat ../id_rsa_qemu) generated_user=antoine generated_group=antoine"

View File

@ -8,7 +8,3 @@ qemu-system-x86_64 \
-device virtio-net,netdev=user.0 \
-netdev user,id=user.0,hostfwd=tcp::5556-:22
# run playbook on aready running qemu vm
# ansible-playbook -i inventory_test.ini playbook.yml --extra-vars "ssh_pub=$(cat ../id_rsa_qemu) geenrated_user=antoine generated_group=antoine"