Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
rb:ansible [12/12/2018 00:43]
andrew
rb:ansible [08/07/2019 16:35]
andrew [Manipulate login shell]
Line 5: Line 5:
 Ansible can also be run from within [[rb:​packer|packer]] from HashiCorp as a Provisioner. Ansible can also be run from within [[rb:​packer|packer]] from HashiCorp as a Provisioner.
  
 +
 +===== Install pip3 =====
 +
 +  root@client01:​~#​ apt install python3-pip
 +  root@client01:​~#​ which pip3
 +  /​usr/​bin/​pip3
  
 ===== Installing Ansible ===== ===== Installing Ansible =====
Line 11: Line 17:
  
  
-  /usr/bin/pip install ansible+  /usr/bin/pip3 install ansible
  
 Testing if the python-yum module is present:- Testing if the python-yum module is present:-
Line 184: Line 190:
       - scored       - scored
 </​code>​ </​code>​
 +
 +
 +===== Conditional code =====
 +
 +<code yaml>
 +- name: Create home directory for cwagent (RedHat Linux)
 +  file:
 +    path:  /​home/​cwagent
 +    state: directory
 +    owner: cwagent
 +    group: cwagent
 +    mode:  0750
 +  when: ansible_distribution_file_variety == "​RedHat"​
 +  ​
 +</​code>​
 +
 +===== Manipulate login shell =====
 +
 +<code yaml>
 +- name: change user default shell to no-login
 +  user:
 +    name: cwdeviceuser
 +    shell: /​sbin/​nologin
 +</​code>​
 +
 +
 +
 +
  
  

rb/ansible.txt ยท Last modified: 16/09/2019 18:11 by andrew