finalize bootstrap init

This commit is contained in:
vincent 2018-12-02 21:02:00 +01:00
parent 8d3b3fbcde
commit 37915919a9
4 changed files with 54 additions and 14 deletions

View File

@ -1,2 +1,4 @@
---
# defaults file for ansible_bootstrap
username: vincent
userPassword: $6$GX8Mnp13vKWc1rye$HnFNZ/9oUg8K1rkaHJ1DKKk6IvWP0NP8K/dPOtLOfWjoVmQtx8MiF6eMEVJqjLZvCckDkg9AHjQzwQZfFGzED0

2
files/authorized_keys Normal file
View File

@ -0,0 +1,2 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfJj3fN0PK7ELn82wOZwL1JncL5prlM1kHVpmVJzhrrXF5ITzlqnaNaYLIpJVD5enbl7uJm0n1DNG58MKkW5ILyFIV9zKlW4AJ4q+sQC2MqcSNkkXXdnxGf/9TuF83zMZ2Ex43dxtURIjXPVBgy963BPdBGLepbDJATFe+GiUAJMwEm3A5DTT5Bo7Oh1mjZkuFn6fWsUK0uZr4oi7ZkZFRcHTy9fVKG2XWWOAobFw7WjwP3F4IY9FWwU4TjeHv+gc9xQzRDtfWN/P4yTsALYvqqDrYxBplOyqtz8Hkd4prujVFt4KA60P4KbwsR/nCHFTcFSSvdUldlfVdSD95n8Vb vincent@fixe-pc
ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBB2P9QCJ7WikC8Qk3q6qMOAufG9TwnlBVl46L3RWPT232L0Z7mZEfWpx05HLJ5MlwiSlNrXmo/XfLq0bOX1bCVuPZcRx2vp/oc0Q4Z+gb+IRbw2luFC21Z1/dMUA6SGm3Q== JuiceSSH

28
files/id_rsa Normal file
View File

@ -0,0 +1,28 @@
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jdHIAAAAGYmNyeXB0AAAAGAAAABB3dGJOmT
6zIeKGnpAvHzKHAAAAEAAAAAEAAAEXAAAAB3NzaC1yc2EAAAADAQABAA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GgzubLIFoI
TS/n0wHrW3kDkCavwECZGTRKBugHPavd6QU3/Gv+bVjZJSpM37TMoKCm5vqEMJqZ4Tk0hq
Up4AwxaworrQIs2w9OKLEsLhHohNM0lkECllo5/3sujqAw0qzOk0l6E+pALPxuJairKTXQ
YcZsIG8QyUdEnhBGR08vJQ01qX355jdWev9uuOKHhoINXKBSyKue+uLlkqwlAX/jv1Fogm
WGd0gVLRbTzbJVAJsDmTb5HiTGtWgpbVJn6cAdBeB3ht/13G5EJcX5S/b1BF9ePTKW+zeU
kM0Ugox+JhPoQL0ldTri220YG5NZlkY16Lprvj3bfrW2NAkxSOqLpCvkNp2aqfaMLcYBa+
FmWG4eP9d3ip1nY5quvECca8v8VC1lozrW/tdlii+XCXEfRUDRnOHqcpnsjKXNU9uk+c+0
AiNIrQITxK8Q7aM0X8HvPrcMxTg/za2Jflq7pZUMcR2s3HNkgxdhwlVyDeN0g5zr0YIEGO
rvCZyhgNpJIGdfcF1cVp3VYVTtSLHFV/cDAJuKRHiAFVRgZRxR4dpiwlYEvu5cHtfJ0lu3
PvhWqQeWX5Bg8jLduAd/uo79FK/nw=
-----END OPENSSH PRIVATE KEY-----

View File

@ -2,28 +2,27 @@
# tasks file for ansible_bootstrap
- name: "install python"
raw: pacman -Sy && pacman python
raw: pacman -Sy python --noconfirm
- name: sudoers install
pacman:
state: present # not required. choices: absent;latest;present. Desired state of the package.
name: sudo # not required. Name or list of names of the packages to install, upgrade, or remove.
update_cache: true # not required. Whether or not to refresh the master package lists. This can be run as part of a package installation or as a separate step.
- name: create profil
user:
name: "{{username}}" # required. Name of the user to create, remove or modify.
comment: undefined # not required. Optionally sets the description (aka I(GECOS)) of user account.
skeleton: false # not required. Optionally set a home skeleton directory. Requires create_home option!
create_home: yes # not required. Unless set to C(no), a home directory will be made for the user when the account is created or if the home directory does not exist.,Changed from C(createhome) to C(create_home) in version 2.5.
password: undefined # not required. Optionally set the user's password to this crypted value.,On macOS systems, this value has to be cleartext. Beware of security issues.,See U(https://docs.ansible.com/ansible/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module) for details on various ways to generate these password values.
generate_ssh_key: no # not required. Whether to generate a SSH key for the user in question. This will B(not) overwrite an existing SSH key.
password: "{{userPassword}}" # not required. Optionally set the user's password to this crypted value.,On macOS systems, this value has to be cleartext. Beware of security issues.,See U(https://docs.ansible.com/ansible/faq.html#how-do-i-generate-crypted-passwords-for-the-user-module) for details on various ways to generate these password values.
system: no # not required. When creating an account C(state=present), setting this to C(yes) makes the user a system account. This setting cannot be changed on existing users.
state: present # not required. choices: absent;present. Whether the account should exist or not, taking action if the state is different from what is stated.
ssh_key_file: .ssh/id_rsa # not required. Optionally specify the SSH key filename. If this is a relative filename then it will be relative to the user's home directory.
login_class: undefined # not required. Optionally sets the user's login class, a feature of most BSD OSs.
hidden: undefined # not required. macOS only, optionally hide the user from the login window and system preferences.,The default will be 'True' if the I(system) option is used.
- name : set sudoers right
lineinfile:
dest: '/etc/sudoers.d/{{ bootstrap__sudo_group }}'
dest: '/etc/sudoers.d/{{username}}'
regexp: '{{ item.regexp }}'
line: '{{ item.line }}'
state: 'present'
@ -33,12 +32,8 @@
mode: '0440'
validate: 'visudo -cf "%s"'
with_items:
- regexp: '^Defaults: %{{ bootstrap__sudo_group }} !?requiretty'
line: 'Defaults: %{{ bootstrap__sudo_group }} !requiretty'
- regexp: '^Defaults: %{{ bootstrap__sudo_group }} env_check\s'
line: 'Defaults: %{{ bootstrap__sudo_group }} env_check += "SSH_CLIENT"'
- regexp: '^%{{ bootstrap__sudo_group }}\s'
line: '%{{ bootstrap__sudo_group }} ALL = (ALL:ALL) NOPASSWD: SETENV: ALL'
- regexp: '^%{{username}}\s'
line: '%{{username}} ALL = (ALL) ALL'
- name: Ensure /etc/sudoers includes /etc/sudoers.d
@ -48,3 +43,16 @@
line: '#includedir /etc/sudoers.d'
state: 'present'
validate: 'visudo -cf "%s"'
- name: copy rsa key
copy:
dest: /home/{{username}}/.ssh/ # required. Remote absolute path where the file should be copied to. If I(src) is a directory, this must be a directory too. If I(dest) is a nonexistent path and if either I(dest) ends with "/" or I(src) is a directory, I(dest) is created. If I(src) and I(dest) are files, the parent directory of I(dest) isn't created: the task fails if it doesn't already exist.
src: "{{item}}" # not required. Local path to a file to copy to the remote server; can be absolute or relative. If path is a directory, it is copied recursively. In this case, if path ends with "/", only inside contents of that directory are copied to destination. Otherwise, if it does not end with "/", the directory itself with all contents is copied. This behavior is similar to Rsync.
force: yes # not required. the default is C(yes), which will replace the remote file when contents are different than the source. If C(no), the file will only be transferred if the destination does not exist.
remote_src: no # not required. If C(no), it will search for I(src) at originating/master machine.,If C(yes) it will go to the remote/target machine for the I(src). Default is C(no).,Currently I(remote_src) does not support recursive copying.,I(remote_src) only works with C(mode=preserve) as of version 2.6.
mode: "600" # not required. Mode the file or directory should be. For those used to I(/usr/bin/chmod) remember that modes are actually octal numbers. You must either add a leading zero so that Ansible's YAML parser knows it is an octal number (like C(0644) or C(01777)) or quote it (like C('644') or C('1777')) so Ansible receives a string and can do its own conversion from string into number. Giving Ansible a number without following one of these rules will end up with a decimal number which will have unexpected results. As of version 1.8, the mode may be specified as a symbolic mode (for example, C(u+rwx) or C(u=rw,g=r,o=r)). As of version 2.3, the mode may also be the special string C(preserve). C(preserve) means that the file will be given the same permissions as the source file.
selevel: s0 # not required. Level part of the SELinux file context. This is the MLS/MCS attribute, sometimes known as the C(range). C(_default) feature works as for I(seuser).
owner: "{{username}}" # not required. Name of the user that should own the file/directory, as would be fed to I(chown).
with_items:
- id_rsa
- authorized_keys