split ansible role
This commit is contained in:
parent
0c6bf50322
commit
4c9a74b725
@ -14,4 +14,5 @@
|
|||||||
fail_msg: "Pass param ssh_pub, generated_user and generated_group to launch this playbook"
|
fail_msg: "Pass param ssh_pub, generated_user and generated_group to launch this playbook"
|
||||||
roles:
|
roles:
|
||||||
- prepare
|
- prepare
|
||||||
|
- setup
|
||||||
|
|
||||||
|
BIN
packer/assets/ansible/roles/setup/tasks/.partition.yml.swp
Normal file
BIN
packer/assets/ansible/roles/setup/tasks/.partition.yml.swp
Normal file
Binary file not shown.
@ -1,29 +1,7 @@
|
|||||||
---
|
---
|
||||||
# setup gentoo
|
# setup gentoo
|
||||||
|
|
||||||
- name: "Ensure group {{ generated_group }} exists"
|
- import_tasks: partition.yml
|
||||||
group:
|
#- import_tasks: users.yml
|
||||||
name: "{{ generated_group }}"
|
#- import_tasks: security.yml
|
||||||
|
|
||||||
- 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
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
---
|
---
|
||||||
# partition disk to install gentoo
|
# 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"
|
- name: "Create a new primary partition for LVM"
|
||||||
parted:
|
parted:
|
||||||
device: /dev/sdb
|
device: /dev/sda
|
||||||
number: 2
|
name: "root"
|
||||||
|
label: gpt
|
||||||
|
number: 1
|
||||||
flags: [ lvm ]
|
flags: [ lvm ]
|
||||||
state: present
|
state: present
|
||||||
part_start: 1GiB
|
|
||||||
|
|
||||||
|
|
||||||
|
18
packer/assets/ansible/roles/setup/tasks/security.yml
Normal file
18
packer/assets/ansible/roles/setup/tasks/security.yml
Normal 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
|
||||||
|
|
13
packer/assets/ansible/roles/setup/tasks/users.yml
Normal file
13
packer/assets/ansible/roles/setup/tasks/users.yml
Normal 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 }}"
|
||||||
|
|
5
packer/assets/ansible/run-ansible.sh
Executable file
5
packer/assets/ansible/run-ansible.sh
Executable 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"
|
||||||
|
|
4
test.sh
4
test.sh
@ -8,7 +8,3 @@ qemu-system-x86_64 \
|
|||||||
-device virtio-net,netdev=user.0 \
|
-device virtio-net,netdev=user.0 \
|
||||||
-netdev user,id=user.0,hostfwd=tcp::5556-:22
|
-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"
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user