RHCE习题( 五 )


解答:[student@workstation ansible]$ wget http://content.example.com/user_list.yml[student@workstation ansible]$ vim users.yml---- name: create developer userhosts: dev, testvars_files:- /home/student/ansible/locker.yml- /home/student/ansible/user_list.ymltasks:- name: create group studentgroup:name: studentstate: present- name: create user in developeruser:name: "{{ item.name }}"groups: studentpassword: "{{ pw_developer | password_hash('sha512') }}"state: presentloop: "{{ users }}"when: item.job == "developer"- name: chageshell:cmd: chage -M 30 {{ item.name }}loop: "{{ users }}"when: item.job == "developer"- name: create manager userhosts: prodvars_files:- /home/student/ansible/locker.yml- /home/student/ansible/user_list.ymltasks:- name: create group opsmgrgroup:name: opsmgrstate: present- name: create user in manageruser:name: "{{ item.name }}"groups: opsmgrpassword: "{{ pw_manager | password_hash('sha512') }}"state: presentloop: "{{ users }}"when: item.job == "manager"- name: chage1shell:cmd: chage -M 30 {{ item.name }}loop: "{{ users }}"when: item.job == "manager"[student@workstation ansible]$ ansible-playbook users.yml --vault-id secret.txt 15、更新Ansible库的密钥按照下方所述 , 更新现有 Ansible 库的密钥:从 http://content.example.com/salaries.yml 下载 Ansible 库到 /home/student/ansible当前的库密码为 AAAAAAAAA新的库密码为 bbe2de98389b库使用新密码保持加密状态
解答:[student@workstation ansible]$ wget http://172.25.250.250/ansible2.8/salaries.yml[student@workstation ansible]$ ansible-vault rekey salaries.yml输入旧密码输入新密码确认新密码16、创建?个名为 /home/greg/ansible/cron.yml 的 playbook,配置 cron 作业,该作业每隔 2 分钟运?并执?以下命令:logger "EX294 in progress",以?户 natasha 身份运?
解答:[student@workstation ansible]$ vim cron.yml---- name: create cronhosts: alltasks:- name: createuseruser:name: natashastate: present- name: create cron for allcron:name: cyminute: '*/2'job: logger "EX294 in progress"user: natasha[student@workstation ansible]$ ansible-playbook cron.yml

推荐阅读