Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #installation of the nonuserids for Sftp servers
- - name: "printing the stages"
- shell: echo "installation has 2 stages, getting the keys from S3
- and running the keys"
- - include: getuserkeys.yml
- tags:
- - sftp,getkey
- # Here we create the nonuserids and restart the sshd agent after
- configuration
- - include: create-user.yml
- tags:
- - sftp,create
- #Creation of the nonuserids for Sftp servers
- - name: List all userkeys present in s3 bucket
- s3: bucket={{ User_S3bucket.name }}
- mode=list
- register: s3objects
- - name: Delete directory to remove old users
- file: path=files/userkeys/ state=absent
- - name: Create directory to place userskeys
- file: path=files/userkeys/ state=directory
- - name: Get/Copy UserKeys from s3 bucket to files/userkeys directory.
- s3: bucket={{ User_S3bucket.name }}
- object={{ item }}
- dest=files/userkeys/{{ item }}
- mode=get
- with_items: '{{s3objects.s3_keys}}'
- - name: List all userkeys present under files/userkeys
- command: ls files/userkeys/
- register: keyfiles
- - name: Create custom file group_vars/users with uid and keys
- template: src=users_sftp.j2 dest=group_vars/users
- - include_vars: group_vars/users
- - name: Add user
- user: name={{ item.name }}
- home={{ item.home }}
- shell={{ item.shell }}
- password={{ item.password }}
- groups=sftpgroup
- append=yes
- state=present
- become: true
- with_items: '{{users}}'
- - name: adding the appropriate ownership and permissions
- file:
- dest: "{{ item.home }}"
- owner: "{{ item.name }}"
- group: "sftpgroup"
- mode: 0755
- recurse: yes
- with_items: '{{users}}'
- users:
- - "{{ user.binny }}"
- user:
- binny:
- name: binny
- comment: binny
- home: /home/binny
- shell: /bin/bash
- password: digit@l@telier
Add Comment
Please, Sign In to add comment