mirror of https://github.com/jumpserver/jumpserver
				
				
				
			
							parent
							
								
									2262b0ecb5
								
							
						
					
					
						commit
						653b996d84
					
				| 
						 | 
					@ -8,7 +8,7 @@
 | 
				
			||||||
      ansible.builtin.user:
 | 
					      ansible.builtin.user:
 | 
				
			||||||
        name: "{{ account.username }}"
 | 
					        name: "{{ account.username }}"
 | 
				
			||||||
        shell: "{{ params.shell }}"
 | 
					        shell: "{{ params.shell }}"
 | 
				
			||||||
        home: "{{ '/home/' + account.username }}"
 | 
					        home: "{{ params.home | default('/home/' + account.username, true) }}"
 | 
				
			||||||
        groups: "{{ params.groups }}"
 | 
					        groups: "{{ params.groups }}"
 | 
				
			||||||
        expires: -1
 | 
					        expires: -1
 | 
				
			||||||
        state: present
 | 
					        state: present
 | 
				
			||||||
| 
						 | 
					@ -18,20 +18,6 @@
 | 
				
			||||||
        name: "{{ account.username }}"
 | 
					        name: "{{ account.username }}"
 | 
				
			||||||
        state: present
 | 
					        state: present
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Check home dir exists
 | 
					 | 
				
			||||||
      ansible.builtin.stat:
 | 
					 | 
				
			||||||
        path: "{{ '/home/' + account.username }}"
 | 
					 | 
				
			||||||
      register: home_existed
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - name: Set home dir permission
 | 
					 | 
				
			||||||
      ansible.builtin.file:
 | 
					 | 
				
			||||||
        path: "{{ '/home/' + account.username }}"
 | 
					 | 
				
			||||||
        owner: "{{ account.username }}"
 | 
					 | 
				
			||||||
        group: "{{ account.username }}"
 | 
					 | 
				
			||||||
        mode: "0700"
 | 
					 | 
				
			||||||
      when:
 | 
					 | 
				
			||||||
        - home_existed.stat.exists == true
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - name: Add user groups
 | 
					    - name: Add user groups
 | 
				
			||||||
      ansible.builtin.user:
 | 
					      ansible.builtin.user:
 | 
				
			||||||
        name: "{{ account.username }}"
 | 
					        name: "{{ account.username }}"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,6 +16,12 @@ params:
 | 
				
			||||||
    label: 'Shell'
 | 
					    label: 'Shell'
 | 
				
			||||||
    default: '/bin/bash'
 | 
					    default: '/bin/bash'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  - name: home
 | 
				
			||||||
 | 
					    type: str
 | 
				
			||||||
 | 
					    label: '家目录'
 | 
				
			||||||
 | 
					    default: ''
 | 
				
			||||||
 | 
					    help_text: '默认家目录 /home/系统用户名: /home/username'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  - name: groups
 | 
					  - name: groups
 | 
				
			||||||
    type: str
 | 
					    type: str
 | 
				
			||||||
    label: '用户组'
 | 
					    label: '用户组'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +8,7 @@
 | 
				
			||||||
      ansible.builtin.user:
 | 
					      ansible.builtin.user:
 | 
				
			||||||
        name: "{{ account.username }}"
 | 
					        name: "{{ account.username }}"
 | 
				
			||||||
        shell: "{{ params.shell }}"
 | 
					        shell: "{{ params.shell }}"
 | 
				
			||||||
        home: "{{ '/home/' + account.username }}"
 | 
					        home: "{{ params.home | default('/home/' + account.username, true) }}"
 | 
				
			||||||
        groups: "{{ params.groups }}"
 | 
					        groups: "{{ params.groups }}"
 | 
				
			||||||
        expires: -1
 | 
					        expires: -1
 | 
				
			||||||
        state: present
 | 
					        state: present
 | 
				
			||||||
| 
						 | 
					@ -18,20 +18,6 @@
 | 
				
			||||||
        name: "{{ account.username }}"
 | 
					        name: "{{ account.username }}"
 | 
				
			||||||
        state: present
 | 
					        state: present
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    - name: Check home dir exists
 | 
					 | 
				
			||||||
      ansible.builtin.stat:
 | 
					 | 
				
			||||||
        path: "{{ '/home/' + account.username }}"
 | 
					 | 
				
			||||||
      register: home_existed
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - name: Set home dir permission
 | 
					 | 
				
			||||||
      ansible.builtin.file:
 | 
					 | 
				
			||||||
        path: "{{ '/home/' + account.username }}"
 | 
					 | 
				
			||||||
        owner: "{{ account.username }}"
 | 
					 | 
				
			||||||
        group: "{{ account.username }}"
 | 
					 | 
				
			||||||
        mode: "0700"
 | 
					 | 
				
			||||||
      when:
 | 
					 | 
				
			||||||
        - home_existed.stat.exists == true
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    - name: Add user groups
 | 
					    - name: Add user groups
 | 
				
			||||||
      ansible.builtin.user:
 | 
					      ansible.builtin.user:
 | 
				
			||||||
        name: "{{ account.username }}"
 | 
					        name: "{{ account.username }}"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,6 +18,12 @@ params:
 | 
				
			||||||
    default: '/bin/bash'
 | 
					    default: '/bin/bash'
 | 
				
			||||||
    help_text: ''
 | 
					    help_text: ''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  - name: home
 | 
				
			||||||
 | 
					    type: str
 | 
				
			||||||
 | 
					    label: '家目录'
 | 
				
			||||||
 | 
					    default: ''
 | 
				
			||||||
 | 
					    help_text: '默认家目录 /home/系统用户名: /home/username'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  - name: groups
 | 
					  - name: groups
 | 
				
			||||||
    type: str
 | 
					    type: str
 | 
				
			||||||
    label: '用户组'
 | 
					    label: '用户组'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue