issue:
cat /etc/dnf/dnf.conf [main] ... excludepkgs = kernel*
sudo dnf install kernel-headers;echo $? Last metadata expiration check: 0:26:44 ago on Fri Jan 26 07:08:42 2024. All matches were filtered out by exclude filtering for argument: kernel-headers Error: Unable to find a match: kernel-headers 1
sudo dnf install kernel-headers --skip-broken;echo $? Last metadata expiration check: 0:25:55 ago on Fri Jan 26 07:08:42 2024. All matches were filtered out by exclude filtering for argument: kernel-headers Dependencies resolved. Nothing to do. Complete! 0
CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release. from cryptography.exceptions import InvalidSignature
pip install cryptography==2.2.2
/usr/lib/python2.7/dist-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.24.1) or chardet (3.0.4) doesn't match a supported version! RequestsDependencyWarning)
pip install --upgrade requests
sudo pip install urllib3==1.22 sudo pip install chardet==3.0
ansible2.0以降の「yum:」「apt:」で「name="{{ list }}"」が指定できるようになった。
with_itemsでループさせない。
[DEPRECATION WARNING]: Invoking "yum" only once while using a loop via squash_actions is deprecated. Instead of using a loop to supply multiple items and specifying `name: {{ item }}`, please use `name: [u'firewalld']` and remove the loop. This feature will be removed in version 2.11. Deprecation warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
- name: ensure a list of packages installed yum: name: "{{ packages }}" vars: packages: - httpd - httpd-tools
macOS v10.12(Sierra)で発生。 CentOS6/7では発生せず。
[ssh_connection] # '%C' by a hash of the concatenation: %l%h%p%r. control_path=%(directory)s/%%C
sudo tail -f /var/log/secure Jul 5 16:27:31 server sshd[1465]: error: accept from auth socket: Too many open files ulimit -n 1024 cat /etc/security/limits.d/90-nproc.conf * soft nproc 1024 root soft nproc unlimited
ulimit -n 1024 cat /etc/security/limits.d/20-nproc.conf * soft nproc 4096 root soft nproc unlimited # もしdaemonのserviceファイルを変えた場合は、以下も必要 sudo systemctl daemon-reload sudo systemctl <daemon> restart
- pam_limits: domain: "{{ item.domain }}" limit_type: "{{ item.limit_type }}" limit_item: nofile value: 65536 with_items: - domain: root limit_type: soft - domain: root limit_type: hard - domain: "*" limit_type: soft - domain: "*" limit_type: hard
sudo reboot
ulimit -n 65536 cat /etc/security/limits.conf root soft nofile 65536 root hard nofile 65536 * soft nofile 65536 * hard nofile 65536
to_nice_jsonで出力すると、「"{...}"」のようにダブルクオートが付いて、文字列として出力される。
to_jsonでは「{...}」で問題ない。
- hosts: localhost gather_facts: no become: no connection: local vars: - var1: key1: val1 key2: val2 tasks: - copy: dest: /tmp/var1.json content: "{{ var1 | to_json }}" - copy: dest: /tmp/var1-nice.json content: "{{ var1 | to_nice_json }}"
{{ broken_object | to_json | from_json | to_nice_yaml }}
cat group_vars/localhost.yml ... cat hosts.ini [localhost] 127.0.0.1 cat playbook.yml - hosts: localhost gather_facts: False connection: local ... ansible-playbook -i hosts.ini playbook.yml fatal: [localhost]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: ... PLAY RECAP ********************************************************************* 127.0.0.1 : ok=2 changed=2 unreachable=0 failed=0 localhost : ok=0 changed=0 unreachable=0 failed=1
"ansible_selinux": false
# pip版をアンインストール pip uninstall ansible # yum版をインストール sudo yum install ansible -y # pyenvを使っている場合 pyenv global system exec $SHELL -l ansible --version ansible 2.6.3
- shell: "rpm -q {{ rpm_name }}" args: warn: false
j2テンプレート中で「{% ... %}」を含む文字列を出力したい場合。
{% raw %} ... {% endraw %}
"{{ lookup('template', '/path/to/template.json.j2') | string }}"
pip list ... ansible (2.5.0) boto (2.48.0) boto3 (1.6.17)
-- group_by: key="{{ inventory_group }}"
tasks: - name: add hosts to localhost group add_host: name: "127.0.0.1" groups: "localhost"
[WARNING]: when statements should not include jinja2 templating delimiters such as {{ }} or {% %}. Found: ansible_devices.{{ item.src | basename}} is defined
when: ansible_devices.{{ item.src | basename }} is defined
when: ansible_devices[ item.src | basename ] is defined
ssh-keygen -N "" -t rsa